beneroth changed the topic of #picolisp to: PicoLisp language | The scalpel of software development | Channel Log: https://libera.irclog.whitequark.org/picolisp | Check www.picolisp.com for more information
seninha_ has joined #picolisp
seninha has quit [Ping timeout: 246 seconds]
aw- has quit [Remote host closed the connection]
aw- has joined #picolisp
aw- has quit [Quit: Leaving.]
aw- has joined #picolisp
aw- has quit [Ping timeout: 260 seconds]
aw- has joined #picolisp
<abu[7]> Jason drives me nuts! He publishes the ugliest and messiest PicoLisp code I've ever seen :(
<aw-> this line is a bit funny:
<aw-> (def 'pil_inc (%@ "getenv" 'S "PIL_INC"))
<aw-> it's kinda ridiculous
<aw-> he has no clue about (sys)
<aw-> and the lowercase naming is bad
<abu[7]> Yep
<beneroth> ¯\_(ツ)_/¯
<abu[7]> He is fond of 'bool'
<aw-> (load "json.l" "/dev/null") is also kind of hilarious
<abu[7]> (when (and (bool dst) (bool gw) (bool flg) (bool msk))
<abu[7]> I wrote it to him, but no reaction
<beneroth> xD
<aw-> and the solo ) on each line... it's not.. lispy
<abu[7]> T
<aw-> indeed, it's very ugly picolisp code
<beneroth> no worries, he surely knows his networking programming \scnr
<aw-> well these are clearly artifacts from a different programming language
<beneroth> T
<aw-> a non-case sensitive one
<aw-> maybe bash?
<abu[7]> or other Lisps or Scheme
<beneroth> then the parens would be nicer
<abu[7]> true
<aw-> yeah beneroth is right
<aw-> other lisps don't place single parens on their own line
<beneroth> I only know this in C/C++ and shell scripts
seninha_ has quit [Quit: Leaving]
seninha has joined #picolisp
<abu[7]> Perhaps we should make it mandatory that published code must pass 'lint'?
<abu[7]> Because otherwise such mess propagates by copy/paste
<aw-> no no
<aw-> i have dozens of published things, no time to review it all
<aw-> you should make it mandatory for people to RTFM before attempting to write picolisp
<abu[7]> :)
<abu[7]> Some kind of exam?
<aw-> ahahahahaa sure
<abu[7]> With mandatory I did not think of existing stufF. More what gets published in the list.
<aw-> oh ok
<abu[7]> Before we answer questions, the code must be cleaned up
<aw-> well my suggestion holds: RTFM first before asking for support
<abu[7]> right
<aw-> abu[7]: don't feel obliged to answer either
<abu[7]> Yeah, but I can't resist :D
seninha has quit [Quit: Leaving]
<aw-> look at the function (de load-routes in his code
<aw-> toward the end
<aw-> it's so funny
<aw-> ) # fi
<aw-> ) # let
<aw-> ) # for
<aw-> ) # in
<aw-> to keep track of the parens
<abu[7]> hihi
<abu[7]> (when (not (= o T)) ... sigh
<abu[7]> He never heard or 'unless' or 't?'
<abu[7]> Also, (= "T" T) wouly give T
<abu[7]> I should not look deeper. Each line I hit makes me shudder.
<abu[7]> Thanks for the supporting mail aw-!
pablo_escoberg has joined #picolisp
<pablo_escoberg> Well, all the above makes me feel a little better, as there are worse offenders than me and at least I try ;-).  But I'm pretty sure I'll keep the `)` on it's own line.  I'm just used to doing a lot of line-level editing which completely breaks when I close all parens on the same line.
<abu[7]> Yeah, you also suffered from the lowcVars syndrome, but I think you improved
<abu[7]> The parens are not dangerous, just ugly
<abu[7]> Editing lines is not lispy, you edit expressions
<abu[7]> Lisp is not Fortran or Assembler
<pablo_escoberg> Yeah, getting the hang of uppercasing the vars.  It should probably be made more clear in the docs that pretty much everything in functions should be upper case.  It left me with the impression that only argments in the definition need to be uppercase.
<abu[7]> "pretty much everything in functions" is not uppercased. Globals are not, only locally bound symbols
<pablo_escoberg> As for editing, I suppose if you're in emacs there are things there that make that kind of thing easier.  But vim is language agnostic and offers lots of cool editing features that work on lines.  closing parens on their own lines makes using those easier.  Though your point is taken.  I will play around more with stuff that works at the `%`
<pablo_escoberg> level and maybe adopt that style.
<pablo_escoberg> I thought globals were copitalized with a`*` prepended, no?
<abu[7]> yes, but symbols like 'car' or 'http' are also global, right?
<pablo_escoberg> yes, but I think of those as builtins, which is to say I shouldn't make any more of them.
<abu[7]> There is no formal distinction for built-ins
<pablo_escoberg> oh, but I guess any function I create does create more of them...
<pablo_escoberg> ok, that also makes sense.
<abu[7]> See the grid function in simul.l
<abu[7]> It creates globals a1, a2, ..
<abu[7]> These are not functions
<abu[7]> but still global
<pablo_escoberg> ah, ok.
<abu[7]> The naming convention are about the binding scope
<pablo_escoberg> IAC, let me go over the docs again for the naming conventions and make sure.  I'll see if I can suggest anything that makes it clearer that all locally bound variables within functions need to be capitalized.  It may be that I just missed something obvious, but it could also be unclear.  BRB
<abu[7]> yeah
<abu[7]> Naming Conventions in ref.html
<abu[7]> Global variables, Global constants, Functions are kind of global values
<abu[7]> Locally bound symbols are the ones we were talking about
<pablo_escoberg> nope, it's pretty clear.  my fault.
<abu[7]> BTW, Local functions have nothing to do with binding
<abu[7]> This is meant file local
<abu[7]> the lexical local context
<abu[7]> It took me a long time to get concious of these separations
<pablo_escoberg> I don't understand the difference.
<abu[7]> Some things are static
<pablo_escoberg> I was curious about that when rereading the section.  I guess I haven't run into any local functions yet...
<abu[7]> ah
<abu[7]> ok
<abu[7]> A local function is one that depends on another function
<abu[7]> Often has free variables defined in another fun
<pablo_escoberg> oh, so defined inside another function; a closure.
<abu[7]> So the local function makes sense only when called from the other one
<abu[7]> No
<abu[7]> (de _fun () (print X))
<pablo_escoberg> ah, I see.
<abu[7]> (de bar () (let X (bla) ... (_fun) ...))
<pablo_escoberg> no wonder I haven't run into it.
<abu[7]> It is not so common, and not good style
<abu[7]> But sometimes more efficient
<pablo_escoberg> yeah, I NEVER code like that.
<abu[7]> @lib.l has (de _pretty "Prg"
<pablo_escoberg> there's always a better way in my experience.
<pablo_escoberg> but I can definitely see where you would want to mark those out as different...
<abu[7]> In my pil21 directory: http://pb1n.de/?095e59
<abu[7]> So there are many :)
<abu[7]> wait, forget the ones in src/
<pablo_escoberg> yikes!  Well, at least I'll know to watch out for them...
<abu[7]> In PilSrc it means lisp-level entry points
<abu[7]> So there are 40: http://pb1n.de/?a69701
<pablo_escoberg> well, I don't understand that stuff anyway, but if the time comes to learn it, I'll bear that in mind.
<abu[7]> No hurry :)
<pablo_escoberg> :)
<pablo_escoberg> so I just got done saying I never code like that, but I am thinking of doing something similar and wonder if it's considered a local function:  If I create a function that takes unevaluated args `Args` and do something like `((car Args) (setq foo 'bar) (cdr Args)` are the functions sent to that function considered local functions?
<pablo_escoberg> oops, forgot to close the last paren...
<abu[7]> I would say the definition of that function does not matter. It is local if it makes no sense outside the context
<abu[7]> It is not callable by itself from the outside
<abu[7]> Like a private symtol, but a local function _foo is accessible for (debug '_foo) etc.
pablo_escoberg has quit [Ping timeout: 246 seconds]
pablo_escoberg has joined #picolisp
aw- has quit [Ping timeout: 246 seconds]
mattx has left #picolisp [The Lounge - https://thelounge.chat]
aw- has joined #picolisp
pablo_escoberg has quit [Quit: Client closed]
pablo_escoberg has joined #picolisp
<pablo_escoberg> Does all this apply to patters (starting with `@`) as well?  Seems to me it shouldn't, but I wanted to make sure.
<pablo_escoberg> patterns*
<abu[7]> Patterns are also treated as being locally bound
<abu[7]> So you will find 'use' calls
<pablo_escoberg> OK, cool.  I figured that since `@foo` won't clobber `foo` it would be ok, but I'll stick to the convention.
<abu[7]> That's true, but it might clobber a @foo in an *outer* function call
<pablo_escoberg> cool.  I figured there was a reason :).
<pablo_escoberg> but wait, if I always bind locally to `@Foo` always, inner functions will clobber outer functions anyway, no?
<abu[7]> One example is 'http'. (use (*Post U L @X) ... ((match '("-" @X "." "h" "t" "m" "l") U)
<abu[7]> or 'test'
<abu[7]> (bind (fish pat? "Pat")
<abu[7]> it finds all @Pat symbols
<abu[7]> No, (use @x saves the outer one
<abu[7]> (use @X (when (match '(a @X b) Str) (foo) (print X]
<pablo_escoberg> yeah, I have to figure out all the differences between `let` `use` `bind` and such.  I know it's mostly to do with evaluating vs non-evalutuating, but there's clearly more than that.
<abu[7]> (de foo () (use @X ... (match '(u @X z) ...)
<abu[7]> No, not eval vs. non-eval
<abu[7]> 'let' is 'use' plus 'setq'
<abu[7]> (let A 7 ...) is (use A (setq A 7) ...)
<pablo_escoberg> oh, ok,
<abu[7]> And 'bind' is dynamic
<abu[7]> 'let' and 'use' have the symbols hard coded
<abu[7]> So you are right, the symbols are not evaluabned
<pablo_escoberg> cool.  guess I have that down :)
<abu[7]> (bind 'A is (use A
<pablo_escoberg> right, cool.
pablo_escoberg has quit [Quit: Client closed]
pablo_escoberg has joined #picolisp
<beneroth> a local or inline functions is one which works with non-global variables it didn't receive in its argument list
<beneroth> that is the definition, I would say
<beneroth> usually only small helper functions. like parts of a bigger function which are used/called multiple times or which work in a big environment with many local variables which would be unnecessary cumbersome (and costing performance) to put all into the argument list
<pablo_escoberg> Yeah, I grok that.  Regardless of how it ends up that way, it's a function that can only be called in certain scopes and should be marked that way.  I will avoid those as much as possible.  Trying to do something similar with closures, and I'm pretty close.
<abu[7]> Yes, well described
<abu[7]> afp
pablo_escoberg has quit [Ping timeout: 246 seconds]