<geri>
so i can have a symbol storing a function also store values inside using its list?
<geri>
xd
<abu[7]>
plist?
<geri>
its plist*
<geri>
yes
<abu[7]>
T
<geri>
thats funny
<abu[7]>
The value of a symbol is just a special, efficient property
<geri>
true
<geri>
when you run dm, what's the pointer in the symbol's value to?
<geri>
i thought you cant create arbitrary functions in C at runtime
<geri>
(well, its llvm now but still)
<abu[7]>
messages all point to the same code
<abu[7]>
'meth'
<geri>
oh
<geri>
so its just syntactic sugar?
<abu[7]>
no
<geri>
vs just (send 'method-name Object . Args)
<abu[7]>
'meth' searches for the symbol whose value it is
<abu[7]>
in the oop hierarchy
<abu[7]>
Yes, (send 'method-name is equivalent
<abu[7]>
brb
<geri>
oki
corecheckno has quit [Remote host closed the connection]
<abu[7]>
ret
<geri>
herro
<geri>
and the sun is down again
<abu[7]>
here not yet
<abu[7]>
in 1 h 20 min
<geri>
well, technically not here either, but its so cloudy it looks like it
<abu[7]>
ah
<geri>
had to unplug one of pc's for the lamp
<abu[7]>
:D
<geri>
lets hope i wont forget to re-plug it again
<geri>
xd
<abu[7]>
you'll learn :)
<geri>
yeah, i believe in my ability to learn
<geri>
B)
rob_w_ has quit [Ping timeout: 248 seconds]
bjorkintosh has joined #picolisp
bjorkintosh has joined #picolisp
<geri>
if i need to share a single list across many functions and flow is not trivial (a bunch of recursion), is it better to use some sort of global variable or using dm and classes?
<geri>
and object variables
<abu[7]>
I would first try global. OOP is for inheritance and polymorphism
<geri>
and encapsulation!
<abu[7]>
yep
<geri>
if i mark a symbol as (local), will it still be visible for a function from the same file after loading the file?
<abu[7]>
"visible for a function" is not the right term, (local) and namespaces are relevant for reading only
<abu[7]>
functions will refer to it
<geri>
will it be visible in pico namespace?
<abu[7]>
Not if it is local in another namespace
<geri>
eh
<abu[7]>
It will be found by 'read' only if that namespace is in the search order
<geri>
hm
<abu[7]>
(symbols '(foo pico))
<geri>
have you ever seen pico namespace not being used?
<geri>
intentionally
<abu[7]>
What do you mean wpth "used" here?
<abu[7]>
*with
<geri>
disabled namespace, just some personal one instead
<geri>
actually doesn't matter
<geri>
i dont think i can put my json reader into its own namespace cause it uses == against some symbols
<abu[7]>
Namespaces are relatively new in pil
<abu[7]>
This should be ok
<abu[7]>
a common case
<abu[7]>
If Json is used, the search order will include it
<geri>
okay
<geri>
then if ill hate the fact tokens are exposed in a global variable ill go to namespaces :D
<abu[7]>
This == is also for all property accesses
<abu[7]>
In PilBox, each App must be in its own namespace
<abu[7]>
as they all run in the same process
<geri>
trying to see if ill be able to make the "proper" json parser simpler by doing tokenizing first
<abu[7]>
ok
<geri>
abu[7]: must they be or it's better to
<geri>
cause collissions
<abu[7]>
ok, just better
<abu[7]>
right
<abu[7]>
especially DB models
<abu[7]>
many apps have a DB
<geri>
shouldnt symbol lookup also be slightly faster in separate namespaces?
<geri>
cause need to look through less stuff
<abu[7]>
Possibly
<abu[7]>
though searching many spaces also takes time
<abu[7]>
IIRC a private function is also not complained about
<abu[7]>
(private) json-skip-whitespace
<geri>
what's the difference between private and local
<abu[7]>
'priv' is a built-in special namespace
<abu[7]>
It is always searched first, but never interned to automotically
<abu[7]>
You can 'private' a symbol multiple times in a file and get a new symbol each time
<geri>
does only that one symbol get interned in priv?
<geri>
and everything else in whatever current namespace is
<geri>
like, if i do (private) json-skip-whitespace and in its body i have 'hello
<geri>
where's that hello interned
<abu[7]>
in the current normal namespace
<geri>
okay good
<geri>
then private is probably a good solution
<geri>
(private) (SYM1 sym2) for many?
<abu[7]>
Yes
<geri>
how do you format many private symbols?
<geri>
(hello
<geri>
world
<geri>
test)
<geri>
?
<abu[7]>
I make a single line
<abu[7]>
without indent
<abu[7]>
just wrap
<abu[7]>
Not beautiful ;)
<geri>
very not beautiful
<abu[7]>
Your example above would be more consistent
<abu[7]>
But gets very large
<geri>
yeah...
<geri>
tough
<abu[7]>
see eg. @lib/vip.l
<geri>
we need a reverse private
<geri>
everything is private until you say otherwise
<abu[7]>
This would break the Lisp reader logic
<abu[7]>
Intern new symbols if the reader does not find them
<geri>
;-;
<abu[7]>
Transients are poon man's private syms
<abu[7]>
No namespaces at that time
<geri>
so (de "json-skip-whitespace" ...)?
<abu[7]>
T
<abu[7]>
ugly
<abu[7]>
Sorry, must stop
<geri>
xd
<abu[7]>
Kids and grandkids visited
<geri>
ah
<geri>
have fun!
<abu[7]>
Later :)
<abu[7]>
Thanks!
corecheckno has quit [Remote host closed the connection]
corecheckno has joined #picolisp
<geri>
silly idea - you could define a function like (de func . body) and call it inline with (~func) to use it as a "macro"/inline without a function call
<geri>
if it takes no arguments anyway
<abu[7]>
T
<abu[7]>
But it is not faster
<geri>
~ is slow?
<abu[7]>
Exactly the same
<geri>
wouldnt it be faster if you do the tiny function call a lot
<geri>
its only read once
<abu[7]>
Then (run '`(cdr fun))
<abu[7]>
This avoids a funcall
<abu[7]>
just the bodg
<abu[7]>
body
<geri>
and its still usable as a standalone function
<abu[7]>
T
<abu[7]>
(fun) just gets the value and calls at a function
<abu[7]>
The in
<abu[7]>
line takes the CAR
<abu[7]>
and calls at a function
<abu[7]>
So it is the same
<abu[7]>
(run '`(cdr fun)) avoids the evExpr() overhead
<abu[7]>
bind the (non-existent) arguments
<geri>
and could wrap it in another read macro if verbose
<geri>
xd
<geri>
fun
<geri>
(~func) looks so nice though
<abu[7]>
But just (func) looks even nicer ;)
<geri>
but slower
<abu[7]>
No
<abu[7]>
perhaps faster
<geri>
🤔
<abu[7]>
evList() first tries for symbol
<geri>
so if list is a single symbol itll skip all other stuff?
<geri>
s/is/has only/
<abu[7]>
Which list?
<geri>
(func)
<geri>
other stuff == binding nonexistent arguments
<abu[7]>
(run '`(cdr fun)) would skip it
<abu[7]>
But the code gets bigger
<abu[7]>
more gc
<geri>
and more obfuscated
<abu[7]>
worse cache
<abu[7]>
yes
<abu[7]>
I think the differences in speed for all 3 versions are not measurable
<geri>
cant just call the functions in a loop?
<abu[7]>
Interpreting the body of fun takes time
<abu[7]>
Which functions?
<abu[7]>
(bench 999999 (... (func) )) ?
<geri>
(de fun () (prinl "Hi"))
<geri>
(bench (do 10000 (fun)))
<geri>
(bench (do 10000 (~(cdr fun))))
<geri>
(bench (do 10000 (run '`(cdr fun))))
<abu[7]>
T
<geri>
second one broken
<abu[7]>
Thought so
<abu[7]>
needs a quote
<geri>
no wait
<abu[7]>
('(~fun)) ?
<abu[7]>
or ~(cdr fun)
<geri>
(de fun2 . (prinl "Hi")) (bench (do 10000 (~fun2)))
<geri>
but again, fun2 is not usable in standalone mode then
<geri>
honestly not sure about timing, its kinda all over the place on my machine
<abu[7]>
(de fun2 . (prinl "Hi")) is not useful
<abu[7]>
binds 'prinl'
<abu[7]>
and returns "Hi"
<abu[7]>
same as (de fun2 prinl "Hi")
<geri>
yeah its not a function
<geri>
its a snippet
<abu[7]>
ah, ok
<geri>
sec, let me try in xterm
<abu[7]>
so ~(cdr fun) is perhapt the best
<abu[7]>
Splices the body
<abu[7]>
'run' is not needed
<geri>
yeah probably
<geri>
1 less function call too
<geri>
even if its a builtin
<geri>
it still runs all over the place
<geri>
~ seems to be only slightly in front of other two
<geri>
like 0.010s difference for 100000 runs
<abu[7]>
Must be ~(copy (cdr fun)) though
<abu[7]>
~ is destructive
<abu[7]>
Othervise fun is concatenated
<geri>
i ran the thing many times without copy and fun is the same
<geri>
hmm
<geri>
or you mean if you change fun
<abu[7]>
No
<abu[7]>
fun is modified if you do (a ~(cdr fun) b c))
<abu[7]>
(b c) is concatenaded to fun
<geri>
oh
<geri>
:(
<geri>
no stylish function calls, very sad
<geri>
macro calls*
<abu[7]>
You need just to copy
<abu[7]>
: (de f () (a))
<abu[7]>
-> f
<abu[7]>
: f
<abu[7]>
-> (NIL (a))
<abu[7]>
: (1 ~(cdr f) 2 3)
<abu[7]>
-> (1 (a) 2 3)
<abu[7]>
: f
<abu[7]>
-> (NIL (a) 2 3)
<geri>
yeah ive seen it
<geri>
i dont like that inlining code has to be ugly
<abu[7]>
true
<geri>
i really like (case X (`(chop "a bunch of symbols")))
<geri>
very meta
<abu[7]>
T
<geri>
honestly separate lexer and parser for json feel kinda nastier
<geri>
i guess you need enough complexity to justify that or something
<geri>
i even got a nice state machine for lexing exactly one value