ChanServ changed the topic of #picolisp to: PicoLisp language | Channel Log: https://irclog.whitequark.org/picolisp/ | Check also http://www.picolisp.com for more information
Blukunfando has quit [Ping timeout: 240 seconds]
mtsd has joined #picolisp
orivej has quit [Ping timeout: 272 seconds]
orivej has joined #picolisp
orivej_ has joined #picolisp
orivej has quit [Ping timeout: 272 seconds]
mtsd has quit [Quit: Leaving]
<aw-> Regenaxer: here?
<Regenaxer> Jup
<aw-> great
<aw-> hi
<Regenaxer> Hi aw- :)
<aw-> i'm trying to figure out something strange with C/native
<aw-> i use (struct P '(B . 8)) to extract a structure but it always gives strange values
<aw-> whereas when i use (struct P '(S)) then i get a string
<aw-> (B . 8) gets me a list with 8 integers, but they always change
<Regenaxer> (struct P 'S) should give the string
<Regenaxer> if P points to it
<aw-> hmmm
<aw-> it doesnt.. i have to use '(S)
<aw-> (struct P '(S))
<Regenaxer> then you have a pointer at P
<Regenaxer> and '(B . 8) gives the bytes of the *pointer*
<aw-> ahhhhhh
<aw-> yes that makes sense
<Regenaxer> Is it pil21?
<aw-> yes pil21
<Regenaxer> ok
<Regenaxer> cause 'S was not supported iirc
<aw-> ugh.. i'm still reading (native) docs for pil64.. maybe i'll switch it now
<Regenaxer> yeah, it is not public yet
<Regenaxer> I use (doc 'native) in the repl, this works
<aw-> i usually load them locally
<Regenaxer> ok
<aw-> so if I get a pointer, then I need to extract the pointer?
<Regenaxer> hmm, does '((B . 8)) work?
<Regenaxer> I don't remember
<aw-> no
<Regenaxer> ok
<aw-> still random numbers
<Regenaxer> you have do inderect the pointer first
<Regenaxer> (struct P '(P))
<Regenaxer> so this should work:
<Regenaxer> (struct (struct P '(P)) '(B . ...
<Regenaxer> no
<Regenaxer> (struct (struct P 'P) '(B . ...
<Regenaxer> I think ;)
<Regenaxer> or (val (adr P))
<Regenaxer> (struct (val (adr P)) '(B .
<Regenaxer> val (adr is probably more efficient
<aw-> ok i'll try that
<aw-> thanks!
Blukunfando has joined #picolisp
<aw-> Regenaxer: need to update native.html as well
<aw-> under '<p>Examples for function calls, with their corresponding C prototypes:'
orivej_ has quit [Ping timeout: 256 seconds]
<Regenaxer> Ah, ok, thanks!
<Regenaxer> hmm, it is I think
<Regenaxer> (native "lib.so" "fun" 'P)
<Regenaxer> in pil21/doc
<Regenaxer> in pil64 it was 'N
<aw-> hmmm
<aw-> (adr P) segfaults
<Regenaxer> I don't think so. It is probably 'val'
<Regenaxer> adr does not access memory
<Regenaxer> Don't try (val (adr P))
<Regenaxer> it is *not* a Lisp expression
<aw-> oh
<Regenaxer> the repl tries to print after ->
<Regenaxer> So it is also not good to pass to 'struct'
<aw-> (struct (val (adr P)) '(B . 8))
<aw-> segfault
<Regenaxer> yes
<Regenaxer> same reason
<Regenaxer> also not good to pass to 'struct'
<aw-> ???
<aw-> you wrote it
<Regenaxer> yes, a quick and dirty shortcut
<Regenaxer> wrong idea
<aw-> ok
<Regenaxer> stay with the first one
<Regenaxer> (struct (struct P '(P)) '(B . ...
<Regenaxer> I thought to avoid the inner 'struct'
<Regenaxer> I don't see a simpler way atm
<Regenaxer> double indirection
<Regenaxer> you have a 'S' pointer
<Regenaxer> but want bytes
<aw-> but it's really just a pointer in a C struct
<Regenaxer> yes
<Regenaxer> a pointer to *another* struct
<Regenaxer> a string is an array of bytes
<aw-> maybe i should change the definition
<Regenaxer> in a separate memory area
<Regenaxer> Why do you need bytes (I asked already ;)?
<aw-> i'm just trying things
<aw-> proof-of-concept
<Regenaxer> (chop (struct 'S)) better
<aw-> that doesn't work with multibyte strings
<Regenaxer> What is a multibyte string?
<aw-> ∛
<aw-> like that
<Regenaxer> this is a multi-byte *character*
<aw-> yes yes that's what i mean
<Regenaxer> 'chop' works good
<Regenaxer> (chop "東京")
<Regenaxer> multi-char
<Regenaxer> the bytes are not useful usually
<Regenaxer> it is characters
<aw-> yeah.. it's fine.. this discussion is just going in circles. Sorry, let's just forget it
emacsomancer has quit [Quit: WeeChat 2.9]
emacsomancer has joined #picolisp
orivej has joined #picolisp
<beneroth> sounds like aw- talked about C++ wide characters?
<beneroth> nvm
<Regenaxer> I think it is UTF-8
<Regenaxer> He wants to process them byte-wise
<Regenaxer> (but doesn't tell us his secret ;)
<Regenaxer> (but doesn't tell us his secret plans ;)
<Regenaxer> Switching this IRC client to pil21 now ...
Regenaxer has left #picolisp [#picolisp]
Regenaxer has joined #picolisp
<Regenaxer> OK, let's see if all works as before
<Regenaxer> The IRC server and client are available at: https://software-lab.de/irc.tgz
<beneroth> Regenaxer, I think you might be wrong about UTF-8. because C/C++ has no notion of UTF-8 (or well, many different ones, every library coming with another string type...)
<beneroth> but even when it is UTF-8, there are cases where such stuff needs to be handled byte-wise, to ensure and check (security) message sizes etc.
<beneroth> to deal with untrusted client/peer
<beneroth> of course if the interface/input/user can be trusted, then your approaches are way easier, more efficient and better.
<beneroth> but as soon as you need to interface with foreign software this is not to be guaranteed anymore
<Regenaxer> right
<Regenaxer> But aw- asked several times how to convert unicode to utf8 bytes