neuroevolutus has quit [Ping timeout: 256 seconds]
rob_w has joined #picolisp
neuroevolutus has joined #picolisp
neuroevolutus has quit [Client Quit]
fuxoft has joined #picolisp
<fuxoft>
Hello. Is there a page with all PicoLisp Rosetta Code solutions to see? I found a link to https://software-lab.de/rosettacode.l but that page does not exist.
<abu[7]>
OK, I uploaded rosettacode.l to software-lab.de, but it is quite old and only what I did back then
<fuxoft>
So to learn PicoLisp, it's better to browse through current solutions on rosettacode.org? Are they more up-to-date?
<abu[7]>
I think so. I did some more, and others (eg. tankf33der) too
<fuxoft>
OK, thanks. It was just slightly cumbersome to navigate through them. AFAIK RosettaCode.org does not allow you to see "all solutions in language XY"
<abu[7]>
I think the above page lists them all (?)
<fuxoft>
But they might be "imperfect" older versions?
<abu[7]>
Not sure. I expect them to point to all current solutions
<fuxoft>
Great!
<abu[7]>
Problem is that some are still for pil64and possibly incompatible with pil21
<fuxoft>
I will keep that in mind, thanks
fuxoft has quit [Quit: Client closed]
bjorkintosh has joined #picolisp
rob_w has quit [Remote host closed the connection]
fuxoft has joined #picolisp
<fuxoft>
Hello.
<fuxoft>
Is it possible (e.g. using *Dbg and/or macros) for a function to know the source file and script line from which it was called?
<fuxoft>
E.g. to print "Hi, this nice debug function was just called from line 13 of file mymod.l"
<fuxoft>
I know that *Dbg allows me to see the line and filename where the symbol was defined but that's not what I want.
<fuxoft>
I also know that (trail) allows the function to find the actual code that called it.
<abu[7]>
Yes, 'trail' is the runtime env, and in '*Dbg' is the source location.
<abu[7]>
(in debug mode only)
<abu[7]>
It is the 'de' or 'def' call
<fuxoft>
I think I understand that but that does not do what I need.
<abu[7]>
Otherwise you get the current location with 'file'
<fuxoft>
Let's say I have defined a function (de myDbg () ....). I call this function from 10 different places in my program. After each call, the message should be printed: "myDbg was just called from line X, file Y"
<fuxoft>
Oh, so this could probably be done using read-macro and (file)...
<abu[7]>
Yes, so (file) should do
<abu[7]>
I thought not a read-macro
<abu[7]>
a plain (file) call
<abu[7]>
a read-macro would give the place of definition
<fuxoft>
But a plain (file) call will tell me where in my program I currently am, not from where I was called...?
<abu[7]>
The current input stream
<fuxoft>
So I'd have to call (file) during all those 10 calls, not just inside the myDbg function.
<abu[7]>
No, just in myDbg
<abu[7]>
can be nested arbitrarily deep
<abu[7]>
It is always the *current* script
<fuxoft>
Ooooh, I see, I've tried it.
<fuxoft>
But that still doesn't do quite what I'd like because:
<fuxoft>
In the top level I call (fun1). fun1 calls (fun2). fun2 calls (myDebug). The (file) inside myDebug prints the location where I called (fun1), not the location where fun2 called (myDebug) - which I'd like.
<abu[7]>
Hm, depends on how "location" is defined
<fuxoft>
The line number and filename
<abu[7]>
There is always just one single stream
<abu[7]>
where 'read' is called
<abu[7]>
established by 'load' or 'in'
<abu[7]>
read-eval (and perhaps print)
<fuxoft>
Let's have a script like this:
<fuxoft>
(de myDbg () (println (file)))
<fuxoft>
(de fun2 () (myDbg))
<fuxoft>
(de fun1 () (fun2))
<fuxoft>
(fun1)
<abu[7]>
yes
<fuxoft>
When I run it, it prints the line number of (fun1) call.
<fuxoft>
I'd like to know the location of (de fun2 () (myDbg)), e.g. the place that directly calls myDbg
<abu[7]>
fun2 is constant
<abu[7]>
always the source file of fun1
<fuxoft>
Yep, in this specific case, I could solve it by getting the *Dbg info of fun2.
<abu[7]>
(de fun2 stores in *Dbg
<abu[7]>
fun1 depends on (file)
<fuxoft>
Yes.
<fuxoft>
Maybe I am approaching this the wrong way from the beginning. I'll try to explain what I am trying to accomplish:
<abu[7]>
ok
<fuxoft>
I've got a complex application. At various places in this application, I call (myDbg val val val ....) to quickly dump some debug data.
<fuxoft>
In the debug log, I'd like to see that this specific log line was produced by (myDbg) call on line X, file Y. Without me having to manually specify for each call (myDbg "parser.l, main fun" val val...)
<abu[7]>
Map over (trail)?
<abu[7]>
and then (file) for the top level call
<fuxoft>
Oh, you mean digging through (trail) until I find something that has *Dbg defined?
<abu[7]>
All have *Dbg
<abu[7]>
all CARs
<abu[7]>
and then (file) also always
<fuxoft>
E.g. I will have (de myFun () ....
<fuxoft>
Then (myFun definiton contines for 20 lines.
<fuxoft>
Then (myDbg ....) call.
<fuxoft>
Then another 20 lines and then the end of myFun definition.
<abu[7]>
The line nu
<fuxoft>
*Dbg will only be there for the line where myFun definition started, no?
<abu[7]>
mber in *Dbg is that of 'de'
<abu[7]>
Right
<fuxoft>
Yes, that's how I understood it.
<abu[7]>
T
<abu[7]>
read -> (de ..
<fuxoft>
So I could find the line where the definition of myFun started. But I cannot find the line number where the call to (myDbg) happens.
<abu[7]>
The line is recorded once for each read
<abu[7]>
yes
<abu[7]>
It would be a lot of overhead
<fuxoft>
OK, that could probably also be useful...
<abu[7]>
to record every subexpressios
<fuxoft>
So there is no way for read-macro to know the exact line where I am RIGHT NOW, when executing the macro?
<abu[7]>
Yes, the info is not logged during read
<abu[7]>
You could call grep
<abu[7]>
to get precise locations
<fuxoft>
And find it retroactively, ok...
<fuxoft>
Interesting possibilities.
<fuxoft>
I just had to ask if I am not missing something simpler.
<fuxoft>
Thanks.
<abu[7]>
Unfortunately there is no direct way
<fuxoft>
OK. I quite understand why this wouldn't be feasible for PicoLisp.
<abu[7]>
The reason is that *all* reads would slow down
<fuxoft>
Completely different question:
<fuxoft>
When I do e.g. (setq "X" 1), the correct way to get "X" to its "unused" state is not (undex '"X") but.... what? Is it (setq "X" '"X")?
<fuxoft>
*undef
<abu[7]>
Yes, (setq "X" '"X")
<abu[7]>
Transients are auto-quoting
<fuxoft>
So that basically removes "X" from memory, as if it never existed? Or does it still occupy the cell?
<abu[7]>
It is not removed
<abu[7]>
Perhaps later by the garbage collector
<abu[7]>
if it is not referenced anywhere
<abu[7]>
For example, in the REPL it is still referenced by @, @@ and @@@
<fuxoft>
Is this similar with non-transients? E.g. when I do (setq X 1) (undef 'X), is X still in memory, with value NIL, or is it actually removed?
<abu[7]>
Non-transients are in some namespace(s), so always referenced
<fuxoft>
OK thanks.
<abu[7]>
You can 'zap' (unintern) them
fuxoft has quit [Quit: Client closed]
neuroevolutus has joined #picolisp
beneroth has quit [Quit: Leaving]
neuroevolutus has quit [Quit: Client closed]
neuroevolutus has joined #picolisp
lagash has quit [Remote host closed the connection]
neuroevolutus has quit [Ping timeout: 256 seconds]
neuroevolutus has joined #picolisp
neuroevolutus has quit [Ping timeout: 256 seconds]
neuroevolutus has joined #picolisp
neuroevolutus has quit [Ping timeout: 256 seconds]