***wxie1 is now known as wxie
***apteryx_ is now known as apteryx
***jonsger1 is now known as jonsger
***jonsger1 is now known as jonsger
***maav is now known as miguel`
***miguel` is now known as maav_
***maav_ is now known as maav
***chrislck1 is now known as chrislck
<lampilelo>Is there an easy way of interfacing a c array with guile code? I found you can cast the c pointer to scm pointer with scm_from_pointer() and then scm_pointer_to_bytevector(). Is this the preferred way? scm_from_pointer takes a finalizer as an argument so i guess it takes ownership of the data, is there a way that doesn't do that? <lampilelo>the thing is i'm writing a wrapper for a c++ library so i'm not doing that from scheme <leoprikler>lampilelo: it optionally takes ownership, but if you destroy the data from C you might have a dangling pointer from scheme, which would be bad <mwette>Ah Maybe use guardians? Not sure that has a C interface. <leoprikler>if you can ensure, that these scheme pointers will be invalidated in the destructor of your class, that should be fine <lampilelo>leoprikler: that's not a problem, the pointer will live shorter than the data <lampilelo>do you have any experiences with mixing guile and c++? will guile try to manage my c++ memory? <leoprikler>Not exactly, but I did some Guile+Vala and it's very doable. Guile won't claim ownership until you instruct it to. ***jonsger1 is now known as jonsger
<str1ngs>when you cringe but all the tests pass? <lampilelo>when you write a lot of code and there are 0 problems with it <emys>hi, is it possible to somehow pass a specific environment to `macroexpand' ? I mean in common-lisp its an optional parameter, in guile there seems to be none.. <emys>is the something like (with-module-as-current-module (macroexpand '(let ((x 1)) x)))? <mwette>but replace (current-module) with your env <emys>hmm, maybe its ok if I explain some more context. I am trying to compile s-expressions to tree-il for a language I am implementing. Since I read in the docs that the scheme->tree-il compilation is basically just macroexpansion, I wondered whether I could implement my compliation using macro definitions. But for that I would need some way to pass in a fairly clean environment I guess. Dunno if this is plausible actually for <emys> a non-scheme language to use the macro system for this. ***jonsger1 is now known as jonsger
<leoprikler>If you already have s-expressions, wouldn't the natural thing be to perform some pattern matching on them, so that the result is Tree-IL? <leoprikler>but regarding your question, you can (save-module-excursion (set-current-module my-module) ...) <emys>leoprikler, yeah thats what I am doing right now, but I guess using syntax-case for hygienic transformations has some appeal <leoprikler>oops, of course you'd need to wrap that in a lambda <emys>I guess I'll figure that out, having the procedure names will help me tremendously <leoprikler>Of course, you can just implement your own language as a set of syntax-cases on top of scheme, but that'd be a step higher on the compile tower if I'm not mistaken. <mwette>did you look at language/scheme/compile-tree-il.scm ? It uses (set-current-module env) then calls macroexpand <mwette>^ under (save-module-excursion ....) <rekado>emys: if your language can be transformed to s-expressions you can build a simple compiler extension like leoprikler mentioned. <rekado>that’s what guile-xcb does, and how guile-aws compiles JSON to .go <mwette>but guile's scheme->tree-il is just calling macroexpand, so maybe emys has something there <mwette>Also, (ice-9 match) may be useful. <emys>ice-9 match is what I currently use in the procedural transformations that I do <mwette>I have done several lang's in Guile and use: lang --[parser]--> sxml --[(sxml fold)+(sxml match)]--> tree-il <emys>I guess looking at constructors like (let names gensyms vals exp) I do wonder how scheme implementation is capable of transforming into an expression that makes use of the original name of a symbol and the gensyms, a bit hard to tell when looking at psyntax.scm <emys>mwette, that sounds like an interesting transformation path. <rekado>during compilation of a JSON file it converts the JSON to Scheme modules. <emys>thanks for these examples! <emys>rekado, I think your guile-aws code is fairly similar to the structure I have now. <emys>I guess I found out how guile uses syntax transformations for let/letrec in the transformation to tree-il, its in psyntax-pp and to me it seems like the syntax transformations are hardcoded directly by providing a lambda function instead of using the syntax-case DSL