IRC channel logs

2022-04-07.log

back to list of logs

<drakonis>mfiano: your best bet would be to read the documentation and tspl4
<mfiano>Oh I habe before. I was looking for books that aren't explaining Guile, but using Guile.
<mfiano>have*
<sneek>chrislck: Greetings
***wonko-th1-sane is now known as wonko-the-sane
<spk121>Hi Guile. If I'm trying to write a compilable DSL using the (language ...) modules, I can write languages in either scheme or Tree-IL, apparently.
<spk121>If I write them in Scheme, will they compile down to *.go? Or does it have to be Tree-IL to compile
<chrislck>sneek: botsnack
<sneek>:)
<lilyp>spk121: There is a Scheme to bytecode tower already in place, so compiling to Scheme would get you to bytecode as well
<lilyp>Depending on your use-case it might be easier to generate Scheme or Tree-IL.
<sneek>chrislck: Greetings :)
<spk121>lilyp: thanks
<abcdw>file-exists? doesn't work on symlinks pointing to non-existing file, it returns #f, when in fact the symlink file itself exists. 1. Is it a bug or the function is documented incorrectly? 2. How to really check if filename exists?
<daviid>abcdw: those procedures follow the symlink, not sure what you are trying to do, but not following symlink(s), use lstat (in 7.2.3 File System)
<abcdw>daviid: it's very pity, according to the documentation I expect `file-exists?` not to follow symlinks. Calling (false-if-exception (lstat path)) is an option, thank you for the idea.
<chrislck>scm_make_hash_table is not documented in guile documentation....
<civodul>it's kinda implicitly documented as make-hash-table
<civodul>usually the Scheme procedure and its C counterpart are documented together
<civodul>looks like an omission
<chrislck>also I'm trying to iterate through a hash_table from C, it's difficult
<chrislck>tried hash_map_to_list (scm_cons, hashmap)... FAIL... scm_cons is not an SCM
<chrislck>scm_hash_for_each needs some more gymnastics
<chrislck>actually hash_map_to_list ((SCM) scm_cons, map) does work
<chrislck>maybe not. anyway.
<stis>chrislck:
<stis>maintain a list of elements available in the hash and you will see the light
<stis>easy if you do not delete hash elements
<stis>more complex but not by much of you do
<stis>will mean super fast iterations mot likely
<stis>standar iteration is much slower
<stis>make sure to store the handles in the list
<stis>that means that you can iterate through the hash and mutate all elements super fast
<stis>also you will keep the iteration in tghe insertion order
<stis>if you need to deletrem the best way is to maintain the number of deleted elements and just set the deleted element to a marker for deleted. Then when you have enough deleted elements, like 50% you can truim the list and not suffer from moving the vector all the time
<stis>growing is a little pain, there are auti growing vector implementations out there.
<stis>but not hard to do it by your own
<stis>or you know the numbet of elements and just allocate the correct sized vector
<mwette>spk121: you create a module (language <your-lang> spec); there you specify target language; see examples in the distribution
<mwette>and I typically compile to tree-it; I generated one to cps but that was tough
<mwette>looking at debug in guile: do boxed var's get noted in dwarf (e.g., in a DW_TAG_variable DIE)?
<spk121>mwette: thanks
<mwette>spk121: yw, and what is not standard is the interface between your reader and your compiler; so, you have to design that
<mwette>my stuff: https://git.savannah.nongnu.org/cgit/nyacc.git/tree/examples/nyacc/lang
<mwette>^ javascript, mlang and tcl are most mature
<civodul>mwette: damnit i hadn't realized there were so many languages in there
<civodul>woow
<civodul>as you probably know, language front-ends could come in handy to solve bootstrapping problems
<stis>mwette: great work!
<mwette>most of those are infants; but ty
*mwette afk
<stis>mwette: if you want to chew on an intersting parser it's trying to parse swi prolog :-)
<stis>hint: configurable operator parser
<chrislck>I fixed my C-based hash_map_to_list ((SCM) scm_cons, scm_hash_map) issue:
<chrislck>first we need to define SCM scm_cons = scm_c_eval_string ("cons");
<chrislck>LOL
<chrislck>well something other than scm_cons which refers to the libguile C function
<stis>yep
<chrislck>shows how much these parens just dissolve in the recesses of the brain
<chrislck>it would be nice(TM) to have a scm_c_hash_for_each (proc, SCM table) which calls proc(SCM key, SCM val) on all elements
<alextee[m]>can guile translate from one language to another?
<alextee[m]>for example I have some scheme scripts that I use as examples
<alextee[m]>I'd like to provide the same examples in ECMAscript without having to rewrite them
<alextee[m]>by "translate" i mean generate source code in the target language
<spk121>alextee[m]: I'm not expert but not as far as I know. Some languages provide converters to scheme or tree-il in their compiler
<spk121>This works, for example (compile '(setq a 10) #:from 'elisp #:to 'tree-il)
<spk121>but this doesn't (compile "0;" #:from 'ecmascript #:to 'scheme)
<alextee[m]>spk121: I see, thanks
<singpolyma>spk121: you can convert any tree-il to scheme though
<spk121>singpolyma: interesting. I've never tried that
<singpolyma>There's a tree-il->scheme around in guile somewhere
<singpolyma>The resulting translation is useful for some things, but probably not for examples since it's unlikely to be idiomatic
<alextee[m]>yeah makes sense
<alextee[m]>how do you use scheme modules from elisp?
<alextee[m]>trying to use the same format as scheme but it says: In procedure public-lookup: No variable bound to use-modules in module (language elisp runtime function-slot)
<alextee[m]>(use-modules (audio position)) (let* ((pos (position-new 1 1 1 0 0))) (position-print pos))
<alextee[m]>trying to translate this to emacs lisp to put it in my examples ^
<lilyp>alextee[m]: you can use @
<lilyp>for a more "generic" solution, see https://gitlab.com/lilyp/tsukundere/-/blob/0.4.x/tsukundere/support/base.el#L90-110
<alextee[m]>lilyp: thanks
<alextee[m]>I implemented this that lets you switch between scheme/ecmascript for now https://manual.zrythm.org/en/scripting/scripting-interface.html
<alextee[m]>with this note https://manual.zrythm.org/en/scripting/overview.html#using-modules
***caleb__ is now known as KE0VVT
<stis>yay I finished my stis-hash module with a full hash implementation
<stis>mail sent to dev list
*stis celebrates with a glas of wine
<ArneBab>stis: yay!