<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 @ ...) ...
<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
<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