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
aw- has quit [Ping timeout: 264 seconds]
theruran has joined #picolisp
<razzy> Good morning to all!
<razzy> will there be Vip wizardry at PilCon?
<Regenaxer> Good mornig razzy!
<Regenaxer> Yes, we can do
v_m_v has joined #picolisp
<v_m_v> You know what would be cool with let? If I could define "else" statement. If any of my arguments is NIL then ... run the else statement. It would reduce a lot of additional lines.
<beneroth> v_m_v, (use Var (if (setq Var (...)) (then...) (else...) (else...))
<beneroth> v_m_v, or if you have many cases, consider doing a explicit FSM with (state)
<v_m_v> can you give me an example ?
<Regenaxer> v_m_v, would such a 'let?' really be such useful?
<Regenaxer> I think the syntax would be quirky
<v_m_v> hmm for example I am getting request to my API. I am getting all the fieled from request "body". If any of them is NIL then I can return to the user "Missing field" :)
<Regenaxer> Now you would just do (if (foo) (let X @ ...) ...
<Regenaxer> (let L (getFields) (if (full L) (doSomething) "Missing field")) ?
<beneroth> v_m_v, use (and)
<beneroth> or full
<beneroth> yes
<beneroth> Regenaxer, T
<beneroth> v_m_v, we often use (and) as a conditional (prog) which exits on first NIL
<Regenaxer> Just occurs to me that 'full' should return the list instead of just T
<Regenaxer> Would be much more useful
<Regenaxer> I change it
<Regenaxer> oops, no
<Regenaxer> non-empty list returns also T
<Regenaxer> I leave it as it is
<beneroth> better don't break that :)
<Regenaxer> Yeah
_whitelogger has quit [Ping timeout: 264 seconds]
_whitelogger has joined #picolisp
<v_m_v> How I can return pure json without HTTP/1.1 200 OK ...etc
<beneroth> (out NIL (print you json...))
<v_m_v> thx
<beneroth> NIL is stdout. instead of NIL you can give a filename as a symbol, or a number for a previously established file descriptor (so a socket number or a file opened with (open))
<beneroth> "+filename" if you want to append instead of overwrite
<beneroth> bbl
<v_m_v> At the end..route in the PIL API's looks really nice and readable https://pastebin.com/AEW9dpPC
<v_m_v> Than you guys for your help
<beneroth> back
<beneroth> v_m_v, nice, congratulations :)
<Regenaxer> v_m_v, 'let' accepts only a single symbol
<Regenaxer> l
<Regenaxer> Did this work?
<Regenaxer> (if (not (== Token NIL)) is just (if Token
<v_m_v> wait ...I have a one mistake ...after last refractoring
<Regenaxer> No worry :)
<Regenaxer> afp, bbl
f8l has quit [Remote host closed the connection]
<Regenaxer> ret
<Regenaxer> (let (EventsJson (mapcar could just be (let EventsJson (mapcar
<Regenaxer> I think the 'or' on top has no meaning
<Regenaxer> as the first expression is always true, no?
<Regenaxer> (assuming the 'let?' is replaced with 'let')
<Regenaxer> 'respond' is not right in this place. It generates its own header
<v_m_v> https://pastebin.com/3L9KUnfJ that version is working ....almost working. The issue is that I am not getting that json at teh end. I have (out NIL ... but still I am not getting it.
<Regenaxer> So the (httpHead ..) on top is better moved to the 'if's else part or so
<Regenaxer> ah! :)
<Regenaxer> cool
<Regenaxer> yeah, makes sense
<Regenaxer> The conses of static values (cons "status" "ok") could be written directly, avoiding runtime conses
<Regenaxer> (list '("status" . "ok") '("errorMsg") (cons "events" T EventsJson))
<Regenaxer> hmm, do the (out NIL make sense?
<Regenaxer> to stdout?
<Regenaxer> Normallt ht:Out goes back to the client
<v_m_v> it was from beneroth ... to replace the (respond
<Regenaxer> I could not follow the earlier discussion
<Regenaxer> Normally the response is sent back over the socket which is open to the client
<v_m_v> ok so I have asked what I can use instead of (respond which is addind a lot of stuff to my json string
<Regenaxer> (httpHead ... then (ht:Out
<Regenaxer> yes, respond is a stand-alone response
<Regenaxer> makes its own header
<Regenaxer> It is useful if you send a single string to the client
<v_m_v> https://pastebin.com/SamkbwQU that version is working but it is not returning the pure json
<v_m_v> printJson can return the pure string but I am using different lib here to change my PIL structure to json.
<v_m_v> so I can not use printJson
<Regenaxer> json-encode builds a string?
<Regenaxer> like packJson?
<Regenaxer> then respond would be fine
<v_m_v> hmmm
<Regenaxer> printJson does not return the json, it outputs it directly iirc
<Regenaxer> hehe, too many json functions now
<Regenaxer> with differing behavior w/o arrays
<Regenaxer> I lost overview
<v_m_v> respond is returning me https://pastebin.com/0wdWsBdq ....and I would like to only get the pure string.
<Regenaxer> the pure string in which form?
<Regenaxer> further double quotes around it?
<v_m_v> So the question is ...how to return json ...:D
<Regenaxer> with quotes inside backslashed
<Regenaxer> I think your last one is fine
<Regenaxer> the body of the response is json
<Regenaxer> Sorry, must go
<Regenaxer> bbl
<v_m_v> I am getting all of those informations from link as a string:/
<v_m_v> Ok..I've solved it :D
<v_m_v> iff
<v_m_v> uff
aw- has joined #picolisp
v_m_v has quit [Remote host closed the connection]
razzy has quit [Ping timeout: 240 seconds]
aw- has quit [Ping timeout: 268 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 260 seconds]
aw- has joined #picolisp
<Regenaxer> ret
<beneroth> wb Regenaxer
<Regenaxer> Hi beneroth!
aw- has quit [Ping timeout: 240 seconds]
v_m_v has joined #picolisp
v_m_v has quit [Remote host closed the connection]
razzy has joined #picolisp
<razzy> hi all, i am unable to configure DB. (has> (meta This Var) Val (get This Var))
<razzy> has> -- Bad message
<beneroth> usually means that you try to set a property which is not declared in the schema
<beneroth> missing (rel)
<razzy> after (put> (request..) 'Joint (request..))
<razzy> if I do requests before, put> works no problem
<beneroth> how does the whole line look like?
<beneroth> the property is called 'Joint ?
<beneroth> property names should be lower case
<razzy> beneroth: could you have a look? i run script on clean DB file http://ix.io/3Ftq
<beneroth> I'll try in some minutes
<razzy> beneroth: thank you :], i do not get what is wrong. I will check log for response.
<beneroth> ok
razzy has quit [Ping timeout: 268 seconds]
<beneroth> : (put> (request '(+Nr) 'pos "in") 'outs3 (request '(+Nr) 'pos "out"))
<beneroth> has> -- Bad message
<beneroth> !? (has> (meta This Var) Val (get This Var))
<beneroth> ? Var
<beneroth> -> ins3
<beneroth> last two lines: debug repl, I typed "Var" to see the value of the variable
<beneroth> your put> is setting value of property 'outs3
<beneroth> 'outs3 you declared previously (rel outs3 (+List +Joint) ins3 (+Nr))
<beneroth> 'outs3 is okay
<beneroth> but the (rel outs3 (+List +Joint) ins3 (+Nr)) specifies with the +Joint that it links to another +Nr object on the 'ins3 property
<beneroth> but you not declared the 'ins3 propery in your schema, (rel ins3 ...) is missing
<beneroth> so add (rel ins3 (+List +Joint) out3 (+Nr)) and similar (rel ins4 ...) etc. so you also have the other end of the +Joint relations declared
<beneroth> then it will work
<beneroth> afk
<Regenaxer> Cool! Nice beneroth
<Regenaxer> :)
<beneroth> ;)
razzy has joined #picolisp
f8l has joined #picolisp
<razzy> beneroth: Thank you. I was thinking, that +Joint makes other side auto-magically :]
<Regenaxer> razzy, yes, this is the case
<Regenaxer> That's the whole point of +Joint
<Regenaxer> (ui, rhymes)
<Regenaxer> You can see that in the family example
<Regenaxer> Put a 'mate' or 'pa' value
<Regenaxer> (put> A 'mate B)
<Regenaxer> the opposite site is set, and also the one of the previous mate (e.g. C) is cleared
<beneroth> razzy, it sets the value automatically, but the schema declaration needs to be made
<razzy> not enough magic i see :]
<Regenaxer> What magic?
<razzy> bad joke, sorry. thank you for help
<razzy> question: second (+Class) in (rel ...) can be only one yes?
<Regenaxer> What is the second class?
<Regenaxer> 'rel' takes a class like +String, +Number or +Date
<Regenaxer> plus Prefix Classes
<Regenaxer> like for the type of index
<Regenaxer> or +List
<razzy> hmm, badly put question
<razzy> on my side
<razzy> Regenaxer: question can i put something before +Nr? (rel ins (+List +Joint) outs (+Nr))
<Regenaxer> yes
<Regenaxer> (+Nr) is a *type*, not a class
<Regenaxer> (+List +Joint) is a type
<Regenaxer> +List is a class
<Regenaxer> The reference in doc/ distinguishes always between classes and types
<razzy> difference class/type is only in programmer head, yes?
<razzy> also, question: example now works only without "+Ref +Number" http://ix.io/3Fuf. can i put searchable number into +Joint relation?
<razzy> +Number in (rel outs ... )
<razzy> i will read doc/ again :]
f8l has quit [Remote host closed the connection]
f8l has joined #picolisp
<Regenaxer> ret
<Regenaxer> +Joint is a subclass of +Link
<Regenaxer> so searchable with 'member' etc.
<Regenaxer> well, no, only if (+List +Joint)
<Regenaxer> searching a plain +Joint makes no sense, there is only one
<Regenaxer> This is not meaningful: (rel outs (+List +Ref +Number +Joint)
<Regenaxer> +Ref and +Joint makes no sense
<Regenaxer> and +Number +Joint neither
<Regenaxer> afp