Re: coredump without '+' final argument
Hi Jason, > ie. we should really track down what is making it coredump in the > non-'+'-suffixed > '(argv)' case when no error was reported when debugging is enabled by > '+' argv suffix - that was my only picolisp specific complaint . As I tried to explain several times in this thread (in this list and in direct mails), this has NOTHING to do with the debug mode. It is accidental that it happens only in debug mode here. Typical for such kinds of bugs which access memory in the wrong way. We call them "Heisenbugs" because they are often hard to reproduce, and disappear as soon as the memory layout is changed some way (e.g. by inserting debug code, calling garbage collection in another moment etc.). More often it is the opposite: Production code crashes, but when trying to debug it it does not. In your case, you accessed the heap via an additional indirection (using the value of the variable instead of the variable itself). So it depends where that indirection points to: If it is some "safe" place to access, nothing happens, if not, it crashes. You should have noticed early on by testing that the code is wrong and does never deliver reasonable results, because it can never have worked correctly. I have lots of other critics too. You seem quite resistant to advices ;) 1. In https://www.mail-archive.com/picolisp@software-lab.de/msg11265.html I told you three errors in the code but you still did not fix them. 2. In https://www.mail-archive.com/picolisp@software-lab.de/msg11264.html I wrote that binding 'cnt' to zero is a fatal mistake (setting a buit-in function to a null pointer. This is also not fixed. 3. In the mails I told you to PLEASE stick with the PicoLisp naming conventions! Having all local variables in lower case is an absolute no-go. You can see this very well with your 'cnt' example above. Using 'Cnt' (case!) would solve it. Please call (lintAll) after loading your code, and fix all those many issues with wrong, unused and unbound variables. ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: best Shebang line for executable scripts
On Sun, Aug 06, 2023 at 07:20:40AM +0100, Jason Vas Dias wrote: > Wow ! I've just figured out the best execve(2) Shebang line for pil scripts: > > $ cat myscript.l > #!/usr/bin/pil -script (car (nth (argv) 1)) (nth (argv) 2) Just for the records, note that (car (nth Lst 1)) is the same as (get Lst 1) which is the same as (car Lst) And (nth Lst 2) is (cdr Lst) > Awesome! I've been missing something like this for ages. I use it sometimes to set up proper namespaces: #!/usr/bin/pil -symbols 'ap 'pico > I'd suggest adding documentation of this to the 'ref.html' > 'Invocation' section . There are examples for this around (though not very prominent), for example in https://picolisp.com/wiki/?serversentevents there is #!/usr/bin/pil -load "@lib/http.l" "@lib/xhtml.l" ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: coredump without '+' final argument - Actually Useful Version!
OK, just to knock it on the head, and putting it together with the previous mail I sent on the best Shebang line, this is actually what I was trying to achieve with the r L_RT.l script : Mode 1: List Routes $ ./L_RT.l -pr 0.0.0.0/0 wlp59s0 192.168.43.1UP,GW 600 { default:1 flags:3 mask:0.0.0.0 prefsrc:192.168.43.70 protocol:dhcp scope:globaltype:unicast} 0.0.0.0/32 * 0.0.0.0 UP,HO 0 { flags:5 mask:255.255.255.255protocol:boot scope:globaltype:blackhole } .. W.X.Y.Z/32 wlp59s0 192.168.43.1UP,GW,HO 50 { flags:7 mask:255.255.255.255protocol:static scope:globaltype:unicast} Mode 2: Be Sourced: $ pil ./L_RT -bye $ Mode 3: Having sourced a script containing a Handler, invoke handler instead: $ pil ./L_RT_rh.l ./L_RT.l pico~Rt 0/0:"192.168.46.70" B0A87A00/24:"192.168.123.1" B0A82D01/32:"192.168.45.10" B0A82C00/24:"192.168.46.70" (hex IPs changed). On 06/08/2023, Jason Vas Dias wrote: > Much better (final) version. > L_RT.l Description: Binary data L_RT_rh.l Description: Binary data
Re: best Shebang line for executable scripts
Yes, but please mention something about '(script ...) in the main 'ref' "Invocation" Section. It took me a long time to find! On 06/08/2023, Alexander Burger wrote: > On Sun, Aug 06, 2023 at 07:20:40AM +0100, Jason Vas Dias wrote: >> Wow ! I've just figured out the best execve(2) Shebang line for pil >> scripts: >> >> $ cat myscript.l >> #!/usr/bin/pil -script (car (nth (argv) 1)) (nth (argv) 2) > > Just for the records, note that > >(car (nth Lst 1)) > > is the same as > >(get Lst 1) > > which is the same as > >(car Lst) > > And > >(nth Lst 2) > > is > >(cdr Lst) > > >> Awesome! I've been missing something like this for ages. > > I use it sometimes to set up proper namespaces: > >#!/usr/bin/pil -symbols 'ap 'pico > > >> I'd suggest adding documentation of this to the 'ref.html' >> 'Invocation' section . > > There are examples for this around (though not very prominent), > for example in > >https://picolisp.com/wiki/?serversentevents > > there is > >#!/usr/bin/pil -load "@lib/http.l" "@lib/xhtml.l" > > ☺/ A!ex > > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe > -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: best Shebang line for executable scripts
On Sun, Aug 06, 2023 at 11:33:32AM +0100, Jason Vas Dias wrote: > Yes, but please mention something about '(script ...) in the > main 'ref' "Invocation" Section. It took me a long time to find! Can you first explain what you are trying to achieve? 'script' in the hashbang line makes no sense to me, because it is the *essence* of hashbang that the whole file gets scripted. Moreover, if there is no (bye) at the end, the script will be loaded TWICE! You wrote: #!/usr/bin/pil -script (car (nth (argv) 1)) (nth (argv) 2) (let (ars (car (rest))) (prinl (car (nth (file) 2)) " ARGS: " (sym ars)) ) (bye) First of all: PLEASE, PLEASE stop publishing code that violates the rules! How often do I have to say that??? Newcomers of PicoLisp will take those bad habits too! At least 'ars' should be 'Ars'. Then, (car (rest))) could be just (next) here. And - again - (car (nth (file) 2)) is unlispy. Use (cadr (file)). BUT: Why do you go through all that trouble? This does the same: #!/usr/bin/pil (prinl (cadr (file)) " ARGS: " (sym (argv))) (bye) Note that 'sym' is bad here. Does a lot of unnecessay conversions. Better is: #!/usr/bin/pil (prin (cadr (file)) " ARGS: ") (println (argv)) (bye) So why do we need 'script'? The example with 'load' #!/usr/bin/pil -load "@lib/http.l" "@lib/xhtml.l" is useful because it has dual use. You can execute it as ./myscript.l and "@lib/http.l" get loaded, or you can (load "myscript.l") in a program where thes files *are* already loaded. Then the hashbang is a comment and the files are not loaded again. ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: coredump without '+' final argument - Actually Useful Version!
Hi Jason, I don't want to be rude, but to put emphasis on what Alexander Burger wrote, your code is really bad. It doesn't follow any of the very simple "naming conventions" of PicoLisp, and it doesn't even follow other LISP "coding conventions". It's hard to read, difficult to grok, messy, poorly documented, and overly complex. Perhaps as a suggestion, you should review existing code by other authors, see "how it's done", and inspire yourself to write in a way that makes it possible for others to help you. Then, it would help greatly if you chop up your large functions into smaller ones. Although I love networking stuff and I'd like to help you out, at the moment your code makes my eyes bleed. Cheers, AW -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Subscribe
Hello Abraham Palmer :-) You are now subscribed Sent from my iPhone -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe