ChanServ changed the topic of #picolisp to: PicoLisp language | Channel Log: https://irclog.whitequark.org/picolisp/ | Picolisp latest found at http://www.software-lab.de/down.html | check also http://www.picolisp.com for more information
shpx has joined #picolisp
shpx has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shpx has joined #picolisp
karswell has joined #picolisp
orivej has quit [Ping timeout: 276 seconds]
shpx has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mangoicedtea has joined #picolisp
aw- has joined #picolisp
shpx has joined #picolisp
emaca-lisper has joined #picolisp
emaca-lisper has left #picolisp ["ERC (IRC client for Emacs 25.3)"]
harryTrout has joined #picolisp
mangoicedtea has quit [Ping timeout: 260 seconds]
alexshendi has joined #picolisp
cilz has joined #picolisp
<cilz> good morning guys
<beneroth> Good morning cilz
<Regenaxer> Hi cilz, beneroth
<beneroth> Guten Morgen Regenaxer :)
<cilz> ;)
rob_w has joined #picolisp
<cilz> Regenaxer, morning question: any special reason to explain why "str?" returns a string when T while other predicates like "num?" return only T?
<beneroth> that actually makes look num? the odd one, I would say.
<beneroth> (isa) also returns the object
<cilz> don't know about (isa) yet, but so far I only found "str?" with this behavior
<Regenaxer> It is very convenient if such functions return the value instead of just T
<Regenaxer> (and (num? (bar)) (foo @))
<Regenaxer> Only functions where NIL is in the set of true results this is not possible
<Regenaxer> eg '='
<cilz> ?? :(
<Regenaxer> (= NIL NIL) must return true, so it can *not* return the argument
<Regenaxer> But many (or most) functions can
<Regenaxer> (let? N (gt0 (read)) ...
<Regenaxer> So N has a number instead of just T
<Regenaxer> (while (gt0 (read)) ... do something ...
<Regenaxer> (while (gt0 (read)) (println @]
<Regenaxer> Otherwise you would need an extra variable
<Regenaxer> (use N (while (gt0 (setq N (read))) (println N]
<Regenaxer> So your statement above "other predicates like "num?" return only T" is not right
<Regenaxer> (num? 'any) -> num | NIL
<Regenaxer> The result is never NIL if it is a number
<Regenaxer> So why return a useless value like 'T'?
<Regenaxer> Also, internally it is faster, as the value is already in the E register
<Regenaxer> No need for loading a value like 'T'
<cilz> ok, got it, thanks ;-) bad morning reading...
<Regenaxer> I think this feature of Lisp, that any value except NIL is true, is extremely powerful :)
<Regenaxer> Saves a lot of work during programming
<Regenaxer> Scheme designers were stupid when giving that away
<beneroth> T. one can view it this way or having a strict separation. in practice, the lisp way (it's similar in C/C++) saves a lot time during programming. separation is a theoretical issue, in practice the programmer knows (or should do) what he does anyway.
<beneroth> separation is only nice in theory, or when the programmers can't program, I think.
<beneroth> have a nice day guys
<beneroth> bbl
<Regenaxer> Many design features in Scheme are not theoretical issues, I believe, but were decided to make compilation easier
<Regenaxer> see you beneroth
<beneroth> good point, though I guess that doesn't apply here as C/C++ views everything as numbers and numbers can always be used as booleans
<Regenaxer> yes, same here
<Regenaxer> and NULL pointers
<beneroth> if it works well for compilers there, it ought work well in scheme too.
<beneroth> aye
<Regenaxer> very convenient
<Regenaxer> I meant other features
<beneroth> (pointer && pointer->doSomething())
<beneroth> I see. then you are surely right :)
<beneroth> cya!
<Regenaxer> like that arguments to functions are not guaranteed to be evaluated left -> right
<Regenaxer> This is a bad limitation in my feeling
<Regenaxer> Same in C
<Regenaxer> (usually right -> left, but not guaranteed, so you often need extra variables)
<Regenaxer> But this is easier to compile, pushing the args on the stack
<cilz> thanks for improving my CS skills!
<Regenaxer> :)
<Regenaxer> Not really CS in the general sense
<Regenaxer> More pil philosophy ;)
<cilz> ya
<cilz> and it's really very interesting
<aw-> hi all
<aw-> beneroth: i agree regarding Scheme
<aw-> #f and #t are so ugly
<Regenaxer> Hi aw-
<clacke[m]> NIL and T are so ugly. `*ducks and runs*`
<cess11> Good morning.
<cess11> Ugly is OK if is simple and practical.
<Regenaxer> Hi clacke[m], cess11
<cess11> If it is and so on.
<Regenaxer> yep
<Regenaxer> But #t or T is not practical at all
alexshendi has quit [Ping timeout: 264 seconds]
<cess11> Agreed.
<Regenaxer> I really like it in C! A string copy is simply: while (*p++ = *q++);
<clacke[m]> I like #t and #f, that they are clearly marked as literal values of a certain class rather than reserved symbols, and I also like the distinction between #f and '() and that '() is truthy. Call me Scheme-infected.
<Regenaxer> Yes, I do ;)
<clacke[m]> :-)
<Regenaxer> No problem, it is the old thing of liking verbose code or not
<Regenaxer> I know people who love COBOL for that :D
<clacke[m]> Just saying "ok NIL is the terminator of a list and also our false value and it refers to itself" is easy, and I appreciate that too.
<clacke[m]> simplicity is good, otherwise I wouldn't be in this channel
<Regenaxer> It is also simply a matter of taste
<clacke[m]> clarity is also good, and so there is this tension
<Regenaxer> T
<clacke[m]> yes
<clacke[m]> #t ;-)
<Regenaxer> (here "T" was good, as "tension" would not be understandable ;)
<Regenaxer> or #t, yes
mtsd has joined #picolisp
<aw-> Regenaxer: how do you feel about YAML ?
alexshendi has joined #picolisp
<Regenaxer> I have not looked at it. Seems something like PLIO?
<aw-> hmmm.. maybe?
<aw-> many people use it as alternative to JSON
<aw-> since it supports more features and is somewhat easier for humans to parse
<Regenaxer> You have to use it?
<aw-> yes always
<aw-> was just curious how you viewed it compared to other formats etc
<aw-> do your customers ever need to modify any Lisp files? config files etc?
<Regenaxer> It looks simple, yes
<Regenaxer> No
<aw-> everything is done through a UI?
<Regenaxer> Most "config" is in the DB
<Regenaxer> except some few init.l files
<Regenaxer> but these are never modified
<Regenaxer> Yes, the user sees only the GUI
<aw-> interesting
<aw-> i'm debating now what is best.. i wrote some tool for my customers but they need to modify a YAML file to fully use it
<aw-> debating if it would be better to use a Lisp config file, and provide a GUI to modify the values
<Regenaxer> Should be all right, as YAML is simple
<Regenaxer> Or even something more simple
<Regenaxer> see RosettaCode "Read a configuration file" and "Update a configuration file" perhaps
<Regenaxer> Simple lines only, old Unix style
<aw-> yes but the debate isn't about the format
<aw-> it's whether the customer should edit the file or not
<Regenaxer> right
<aw-> edit manually, or use a tool/GUI to edit it
<Regenaxer> So a simple line format is best
<Regenaxer> Depends whether the user can use an editor
<Regenaxer> The easiest to *program* for us is a DB and GUI
<Regenaxer> and also for the user
<aw-> right
<Regenaxer> So I never had this problem
<tankf33der> how to get number not T from (call) function ?
<tankf33der> (call "date" "+%N")
<tankf33der> ?
<Regenaxer> 'call' does not return stdout
<Regenaxer> you want (in '("call" ...
<tankf33der> ok
<tankf33der> : (in '(date "+%N") (format (line T)))
<tankf33der> -> 741670089
<tankf33der> works.
<Regenaxer> ok
<Regenaxer> or just (read) instead of (format (line T))
<aw-> nanoseconds
<aw-> i always end up doing (in (list 'cmd ...) because often i want to pass a variable
<Regenaxer> yes, typically
<tankf33der> Regenaxer: indeed
<tankf33der> i've got real reply handshake packet from demo.wireguard.com server
<tankf33der> what a day.
shpx has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<aw-> kernel based VPN?
<aw-> cool
<aw-> hmmm.. they claim nonces are never reused but they keep track of the "greatest count", which means they could theoretically be predictable
<aw-> is this protocol peer reviewed?
_whitelogger_ has joined #picolisp
rob_w has joined #picolisp
alexshendi has joined #picolisp
orivej has joined #picolisp
aw- has quit [Quit: Leaving.]
harryTrout has quit [Quit: Leaving]
<tankf33der> writing announce
<tankf33der> i'm happy bunny.
<Regenaxer> :)
<cilz> what's the Pil counterpart to "null" in CL?
<Regenaxer> 'not'
<Regenaxer> 'not' is also in CL I think, so 'null' is redundant
<cilz> tks will try it
<Regenaxer> If you like, you can do (def 'null not)
<cilz> yes perfect :)
<Regenaxer> :)
<cilz> I'm a bit confused with the behavior of "n0". I'm sure I'm missing something but ca't find out what. It returns T if not 0 even for a num where I would expect something like (n0 7) -> 7. The same behavior as (gt0 7) -> 7
<clacke[m]> what is null / not for?
<Regenaxer> Again the NIL issue here (n0 NIL) -> T
<Regenaxer> so n0 returns a 'flg'
<Regenaxer> null / not checks for non-NIL
<clacke[m]> ah, so it's the null? predicate in scheme
<Regenaxer> or, more correct, for NIL
rob_w has quit [Quit: Leaving]
<Regenaxer> yes, same as in CL then
<Regenaxer> only (not NIL) gives T
<clacke[m]> thought that would have been nullp or something, just null sounds confusing
<clacke[m]> oh, so CL has "null?" too, ok
<cilz> clacke[m]: yes
<Regenaxer> I think 'null' was already in the firsts Lisps
<Regenaxer> And 'not' too
<Regenaxer> So I omitted 'null'
<Regenaxer> 'null' is a bit nonsense, right? There is no null-pointer or zero involved
<Regenaxer> People just kept it for historical reasons
<cilz> Regenaxer: may be. I found a lot of redundancy in CL...
<Regenaxer> yeah
<cilz> back to (n0 NIL) -> T why do we have this result?
<Regenaxer> because NIL is not a number with value zero
<Regenaxer> (=0 0) works in that sense, should give 0
<cilz> yes, it's obvious!!
<cilz> tks
<Regenaxer> So you are right in some way, that 'n0' could return the value if it is not NIL and not 0, but this makes it rather confusing
<Regenaxer> Such primitives should be fast, so coding extra rules into them makes them slower
<Regenaxer> FYI, n0 is currently:
<Regenaxer> # (n0 'any) -> flg
<Regenaxer> (code 'doNEq0 2)
<Regenaxer> ld E ((E CDR)) # Get arg
<Regenaxer> jne retT # No
<Regenaxer> ld E Nil
<Regenaxer> cmp E ZERO # Zero?
<Regenaxer> eval # Eval it
<Regenaxer> ret
<Regenaxer> Instead of 'jne retT' it would need further processing
<Regenaxer> I think this is confusing
<cilz> the first time I saw it I expected a kind of generalised version of gt0 le0 ...
mtsd has quit [Quit: Leaving]
<Regenaxer> yes, I understand
<Regenaxer> Usually, if you need the value, you would use gt0 then
<Regenaxer> (while (gt0 (read)) (println @))
<cilz> ok.
<Regenaxer> This is also better for another reason
<Regenaxer> (read) returns NIL for end of file
<Regenaxer> So (while (n0 (read)) ... might not terminate
<Regenaxer> because (n0 NIL) is also true
<cilz> of course
<Regenaxer> The reference should always show what is returned
<Regenaxer> (help 'gt0) etc
<Regenaxer> or (doc 'gt0)s
<cilz> yes I'm using (help) I also use the reference on Pil's home
<cilz> btw (help) needs w3m to work right?
<Regenaxer> A slight disadvantage of 'help' is that it shows no examples
<Regenaxer> Not (help) but (doc)
<Regenaxer> Or you call (doc 'gt0 "firefox") or so
<Regenaxer> Or set a env variable
<Regenaxer> (sys "BROWSER" "firefox")
<cilz> was not aware of (doc) it's cool!
<Regenaxer> or in your .bashrc export BROWSER=myBrowser
<cilz> w3m works perfectly and keep me in the terminal
<Regenaxer> I prefer w3m, it is very fast, yes
<Regenaxer> also because I set the key bindings to vi-style
alexshendi has quit [Ping timeout: 260 seconds]
alexshendi has joined #picolisp
<cess11> cilz: 'vi and 'doc are very useful.
<cilz> agree
shpx has joined #picolisp
alexshendi has quit [Read error: Connection reset by peer]
<cilz> trying to figure out why (set 'L '(a b c d e f) (cdr L) '(x y)) gives L -> (a (x y) c d e f) and (setq L '(a b c d e f) `(cdr L) '(x y)) gives L -> (a b c d e f) while (setq L '(a b c d e f)) and then (setq `(cdr L) '(x y)) give the expected L -> (a (x y) c d e f)?
<Regenaxer> good :)
<Regenaxer> Think what 'set' does
alexshendi has joined #picolisp
<Regenaxer> And a hint: be careful with ` backquote, it is different from CL
<Regenaxer> So (set (cdr L) X) puts X into the second cell of the list
<Regenaxer> You know what ` does?
<cilz> I believe, it "un quote" doesn't it?
<Regenaxer> nope
<Regenaxer> It is a read-macro
<Regenaxer> It is evaluated at read time
<Regenaxer> So probably not what you want here (?)
<Regenaxer> (cdr L) is *evaluated* while the expression is read
<Regenaxer> and the result used in that expression
<cilz> I understand "set"
<cilz> and that every "any" are evaluated
<cilz> but not the full behavior of setq
<Regenaxer> (setq A 1) is the same as (set 'A 1)
<cilz> if I recall, setq quotes its args right?
<Regenaxer> yes, the first, third, fifth ...
<Regenaxer> That's all
<cilz> ok
<Regenaxer> So what does (setq L '(a b c d e f) `(cdr L) '(x y)) mean?
<Regenaxer> `(cdr L) gives what it is at that moment
<Regenaxer> in your case (b c d e f)
<Regenaxer> because you set L before
<Regenaxer> rather by chance
<Regenaxer> The evaluator sees (setq L '(a b c d e f) (b c d e f) '(x y))
<Regenaxer> Rather nonsense
<cilz> yes
<cilz> then why does work for (set 'L '(a b c d e f) (cdr L) '(x y)) doesn't it see also (cdr L) -> (b c d e f)?
<Regenaxer> because (cdr L) is evaluated
<Regenaxer> ie the second cell of L
<Regenaxer> it is set to (x y)
<cilz> well I need to think a little now to fully understand everything :(
<Regenaxer> good
<cilz> ok after living PIL and trying a fresh (setq L '(a b c d e f) `(cdr L) '(x y)) it gives -> this error (setq L '(a b c d e f) NIL '(x y)) so I understand now your "rather by chance" ;-)
<cilz> so now I have to understand what the "read-marco" fully means...
<cilz> anyway using (setq val key) if I want the val to be evaluated is nonsense, right?
<Regenaxer> Sorry, was away
<Regenaxer> yes, setq evaluates only every second arg
<Regenaxer> 'set' evaluates every arg :)
<cilz> Regenaxer: don't worry ;-) thanks a lot for your kindness
<Regenaxer> ok :)
orivej has quit [Ping timeout: 240 seconds]
shpx has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shpx has joined #picolisp
orivej has joined #picolisp
shpx has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shpx has joined #picolisp
shpx has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]