IRC channel logs

2018-08-09.log

back to list of logs

<ft>Note that every other C developer will look at you funny, though, if you do. ;)
<ft>I mean, in K&R you can also do int foo(a,b,c,d) { ... }, because the parameters will be implicitly int. I think everything that was changed from K&R to ANSI has been an improvement. ;)
<daviid>ft: tx
<daviid>Combinatorialist: tx too
***chimez1 is now known as chimez
***chimez1 is now known as chimez
***eponym is now known as epony
<manumanumanu>What exactly does goops do to macro expansion? defining a generic procedure is ruining an unrelated macro expansion...
<manumanumanu>oh no. I know what happened.
<manumanumanu>phasing issues.
<roelj>Using the FFI, how do I create a pointer to a pointer?
<manumanumanu>roelj: (make-pointer (pointer-address pointer)) ?
<roelj>manumanumanu: I think that just makes a pointer with the same address as "pointer".
<manumanumanu>roelj: i usually use malloc directly for those things. 2 secs and I'll paste you my implementation (that also free's allocated memory using the GC)
<manumanumanu>roelj: https://pastebin.com/knYh0AJD
<manumanumanu>that will allow you to allocate (sizeof size_t)
<roelj>manumanumanu: That's very smart. Thanks!
<manumanumanu>When the allocated memory pointer becomes unavailable to the guile program, it will be freed
<manumanumanu>BIG FAT WARNING
<roelj>That's what the '(dynamic-pointer "free" (dynamic-link))' does, right?
<manumanumanu>exactly
<manumanumanu>that las argument is a guard, and you can leave it out to manually manage the memory
<manumanumanu>to fill the memory you have to access it as a bytevector and write whatever pointer address you have to it.
<roelj>Why is size_t the return type for malloc in your definition?
<roelj>Shouldn't that be '*?
<manumanumanu>no, because I am passing the return-value to make-pointer and explicitly adding a guard function
<roelj>So, glibc's malloc returns a pointer, which you pass to make-pointer. How does size_t affect the return value of c_malloc?
<roelj>It's still the address of the memory location?
<manumanumanu>size_t is the size of a pointer
<manumanumanu>on that platform
<manumanumanu>so most often 32 or 64 bit
<manumanumanu>Why I am asking is because I am implementing racket-styled for loops for guile, and I have been looking at cl LOOP-witchery for ideas to extend it
<manumanumanu>oops
<manumanumanu>wrong channel
<roelj>If I may ask, could you give me an example of a pointer to a pointer using your 'malloc' function? I think I'm lost at the return value of glibc's malloc, and how that is interpreted by make-pointer.
<manumanumanu>first I do (malloc (sizeof size_t))
<manumanumanu>that is a pointer object to size_t bytes in memory
<roelj>Right, and then how do you fill that pointer with an addres?
<manumanumanu>next I do (pointer->bytevector xxxx (sizeof size_t))
<manumanumanu>Then I just write the pointer address to that bytevector
<manumanumanu>probably using (bytevector-u64-native-set! ...) or whatever i is called
<roelj>Isn't that size_t-specific then?
<manumanumanu>yes. you should use different bytevector procedures depending on the size of size_t
<roelj>Right, thanks! I was hoping to avoid having to know the details of the underlying platform.
<manumanumanu>I know. it is rather painful :(
<roelj>Do you use (sizeof size_t) to determine wether it's 32-bit or 64-bit?
<manumanumanu>I do, but there are better ways iirc
<manumanumanu>some (system compile xxx) voodoo
<roelj>Ahh okay
<roelj>Is it correct to state that (= (sizeof size_t) 8) means 64-bit, (= (sizeof size_t) 4) means 32-bit, and (= (sizeof size_t) 2) means 16-bit?
<manumanumanu>yes
<manumanumanu>but I don't know C :P
<manumanumanu>I figure all this out by pulling out almost all my hair over a weekend :D
<roelj>manumanumanu: Alright, I think I got around it.
<roelj>So, the function takes a pointer to a pointer to NULL, and will allocate memory itself. So I just gave it a (malloc (sizeof size_t)), and later on when I need the allocated memory by that function, I used (dereference-pointer xxxx).
<roelj>This way, I don't need to know about whether something is NN-bit.
<roelj>As long as 'dereference-pointer' does its job correctly.
<roelj>And instead of (malloc (sizeof size_t)) I used (bytevector->pointer (make-bytevector (sizeof size_t))).
<wingo>guile's jit is going to be pretty simple, but happily it will be able to inline subr and foreign calls
<roelj>wingo: is it webscale? ;)
<cmaloney>It's web 4.0 because it's A+
<roelj>hehe
<rain2>that's awesome wingo !
<wingo>i think we have to compile to wasm to be webscale ;)
<cmaloney>Do eeeet. :)
<cmaloney>Then we can have a proper scheme in the browser
***chimez1 is now known as chimez
<mechanicalfrogs>hey guys - trying to get Chickadee working and I'm pretty sure I have all the necessary stuff installed - but when I run the provided example code I get this error: https://pastebin.com/BNW3qz1v
<mechanicalfrogs>running (symbol->string #:sdl2) gives me the same error
<daviid>mechanicalfrogs: that is a keyword
<daviid>mechanicalfrogs: keyword->symbol ... then symbol->string, or use srfi-88 which has keyword->string
<mechanicalfrogs>yeah - i'm not sure what's wrong because I'm using example code with latest releases of chickadee and guile-sdl2
<daviid>this has been discussed here recently
<mechanicalfrogs>it's not my code that's causing the error, just the example
<daviid>mechanicalfrogs: yes, we know :)
<daviid>Chickadee probably uses srfi-88 and did not tll you ...
<daviid>mechanicalfrogs: anyway, the best is to define your own keyword->string
<daviid>iirc, srfi-88 has a problem, in the way that it changes the reader ... i don't have ti me to check now, try to search the log about this, r someone may shim in
<mechanicalfrogs>daviid: okay, I'll look through the log - thank you!
<daviid>np!
<amz31>yay!
<amz31>ACTION got a (great of course) idea
<amz31>I will rename culturia.next to asylum
<amz31>I prefer much more that name, 'asylum' seems timeless whereas AI / IA thing can fade away
<amz31>timeless name
<amz31>also, maybe more of interesting, I will drop the biwascheme dependency, I found a ((very) creative) way to avoid javascript altogether, I let you guess how...
<amz31>and last but not least I am ready (at last) to use zehefyu93 because I am now sure this verioned git-like database can be useful in production
<amz31>which means I need to read the 2nd edition of reasoned schemer
<amz31>to add support for it in zehefyu in turn change the database backend in the main project
<amz31>here is the repository to watch / git clone https://framagit.org/a-guile-mind/culturia.next
<amz31>also, I will adopt a chatbot-like user interface and interop maybe with gnunet... dreams.
<amz31> https://github.com/TheReasonedSchemer2ndEd/CodeFromTheReasonedSchemer2ndEd
<amz31>wdyt?
<amz31>please people, let me know what design / graphics do you prefer
<amz31> https://screenshots.firefox.com/MDbwtBy4Tj1iVXrQ/localhost
<amz31>or
<amz31>that design with a video http://hyperdev.fr/ ?
<amz31>well it's prolly not very important