aelius has joined #picolisp
ygrek has joined #picolisp
ygrek has quit [Ping timeout: 244 seconds]
rob_w has joined #picolisp
aw- has quit [Quit: Leaving.]
rob_w has quit [Remote host closed the connection]
geri has joined #picolisp
<
geri>
i have a stupid question :D
<
geri>
how does car work? :DD
<
geri>
more concretely, chkA is confusing me
<
abu[7]>
A little later. We are walkng in the woods and have bad net.
<
geri>
enjoy the walk
aw- has joined #picolisp
<
abu[7]>
Not yet back at the car (the electric one I mean), but a short look: You mean in chkA the (car (needVar .. ?
<
geri>
im kinda wondering why does NIL have a special structure
<
geri>
(de mcar (P) (when (pair P) (car P)))
<
geri>
if you did this, you would do as many runtime checks i think, but nil would just be a symbol
<
abu[7]>
Now in the car
<
abu[7]>
(car NIL) is allowed
<
geri>
but if nil were a symbol and car would return nil for any non-pair, you would have the same effect
aw- has quit [Quit: Leaving.]
<
abu[7]>
Well, the Lisp level 'car' does a check, but all low-level funs that traverse a list dont need to in the innermost loop
<
abu[7]>
(nth Lst 99999)
<
abu[7]>
ok, 'nth' checks ;)
<
abu[7]>
it runs full speed :)
<
abu[7]>
(while (ge0 (dec 'C))
<
abu[7]>
(shift Y) )
<
geri>
(nth '(a b . c) 7) returns c, huh
<
geri>
nth does an (atom) check
<
geri>
so kinda isn't "full speed", no?
<
abu[7]>
'c' is NIL probably
<
abu[7]>
try (1 2 . 3)
<
abu[7]>
should crash phantastically
<
abu[7]>
: (nth (1 2 . 3) 7)
<
abu[7]>
Segmentation fault
<
abu[7]>
The checks on the top level are not time critical (interpretation overhead i 'llvm~evList', but inner loops are
<
geri>
so trading safety for speed
<
abu[7]>
Originally the top 'car' etc also did not check, but here it is use(ul
<
geri>
like lisp-level car didn't check if arg was a pair?
<
geri>
(car 5) would segfault?
<
abu[7]>
I think yes
<
geri>
very fast though
<
abu[7]>
probably only the very first versions ;)
<
abu[7]>
As I said, on the top level it doesn't make much difference
<
geri>
i wonder how much slower would it be with proper checks
<
abu[7]>
The inner loop perhaps by 30 to 50 %
<
abu[7]>
a check and a jump
<
abu[7]>
and jumps are expensive
<
abu[7]>
(prefetch queue)
<
geri>
you know, often in a dynamic programming language you need runtime checks to make sure software is acting as expected
<
geri>
but if it can just segfault then people are forced to write good code around it
<
abu[7]>
yes, this is goo
<
abu[7]>
You can take out the checks for a debugged app :)
<
geri>
i heard some complaints for example about having all values be optional
<
geri>
(de add (X Y) (+ X Y))
<
geri>
even if parameters are required, nothing stops you from doing (add NIL NIL)
<
abu[7]>
I think it is a very convenient feature
<
geri>
i think so too
<
geri>
cause its dynamic anyway, you need your checks if you want your checks
<
abu[7]>
In DB apps often values are missinp
<
abu[7]>
Then just check the final result for NIL
<
abu[7]>
(but (+ 'sym ..) gives an erro
<
geri>
optional parameters are convinient to have either way arond
<
geri>
im starting to really like lua honestly, and it also has all its arguments be optional
<
geri>
its also about simplicity, but its byte compiled
<
geri>
only collection is a table - hashmap/dynamic array hybrid
<
geri>
pretty interesting
<
geri>
do you need to use C interop in your work projects often?
<
abu[7]>
Not so much in commercial projects, but in scripts (tools)
<
geri>
tools like what?
<
abu[7]>
file system access, stack limit
<
abu[7]>
eg symlinks
<
geri>
can do it with (call) too
<
abu[7]>
But for backup it is too slow
<
geri>
i like the fact that you can jump into C for anything picolisp doesnt natively support
<
abu[7]>
or (native "libcrypt.so" .. for passwords
<
abu[7]>
It would be nice if libffi could access Rust too
<
abu[7]>
seems tough though
<
abu[7]>
I want to access the Veilid core libs
<
abu[7]>
is in Rust
<
geri>
i remember something about this
<
geri>
uncharted territory...
aw- has joined #picolisp