IRC channel logs

2022-04-05.log

back to list of logs

<mwette>did you mean 'value instead of 'bytecode? : (compile '(+ 1 2) #:from 'scheme #:to 'value)
<mwette>((compile '(lambda () 9) #:from 'scheme #:to 'value)) => 9
<alextee[m]>mwette: I'm trying to get bytecode as lilyp said so i can run it with scm_call_0(bytecode)
<alextee[m]>so eventually I could do `:from 'otherlang` or something to support other languages too
<mwette>I think you want "value" instead of "bytecode". Try it.
<alextee[m]>mwette: I get the same error
<alextee[m]>I think it doesn't like that I'm passing the script as a string
<alextee[m]>I'm not sure how to pass a script as the first argument to (compile)
<alextee[m]>all the examples I see use (quote)
<alextee[m]>my script starts with a comment for example
<alextee[m]>maybe I should try (compile-file)
<mwette>Script needs to be a literal, I think. For strings you can use scm_eval_string. And I think you can change the urrent-language: (current-language 'ecmascript)
<alextee[m]>oh I think I need to use scm_call_* to call eval-string otherwise I can't pass the current language
<alextee[m]>seems like scm_eval_string() only takes a scheme string
*alextee[m] attempts to call eval-string
<singpolyma>compile-file is best if you have a file. Otherwise eval-string yeah
<singpolyma>You can compile-file to 'value and it's actually eval not compile
<alextee[m]>they seem to do the same thing, I have both a file and the contents so either is fine
<alextee[m]>still getting an error though https://paste.debian.net/1236811/
<alextee[m]>I don't understand which argument is problematic from that error message
<alextee[m]>I'm trying with a test string "(display \"hello\")" for now
<alextee[m]>I think scheme is missing the quote from what I can see there, what is the C API to get 'scheme instead of just scheme?
<alextee[m]>i thought it was scm_from_utf8_symbol() but that doesn't seem to do it
<singpolyma>The scheme is string->symbol
<singpolyma>Or hmm, maybe you want to quote is as well?
<alextee[m]>here is my C code
<mwette>scm_from_utf8_symbol
<alextee[m]> https://paste.debian.net/1236812/
<alextee[m]>this works with guile -s: (eval-string "(display \"hello\")" #:lang 'scheme)
<alextee[m]>just can't reproduce this call with that C code it seems
<alextee[m]>yay I did it
<alextee[m]>SCM eval_string_proc = scm_variable_ref (scm_c_public_lookup ("ice-9 eval-string", "eval-string")); SCM code = scm_from_utf8_string ("(display \"hello\")"); SCM s_from_lang = scm_from_utf8_symbol ("scheme"); SCM kwd_lang = scm_from_utf8_keyword ("lang"); scm_call_3 (eval_string_proc, code, kwd_lang, s_from_lang);
<alextee[m]>well it looks like it can evaluate javascript now but I'm not sure how to use the exported modules from it lol
*alextee[m] uploaded an image: (14KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/dRJnDyzChLrZNinWPtUDCLsu/Screenshot%20from%202022-04-05%2000-24-07.png >
<alextee[m]>or even how to print stuff like (display). console seems undefined
<alextee[m]>anyway thanks for the help! at least I can easily choose a language in the future now that it's just a string in my code
<alextee[m]>will continue using scheme for now
<singpolyma>alextee[m]: oh, do you have questions about guile ecmascript
<singpolyma>You can use display("hello");
*alextee[m] uploaded an image: (136KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/uNaxqXskxfKCbMOmLqifCcSE/Screenshot%20from%202022-04-05%2000-28-04.png >
<alextee[m]>singpolyma: is it possible to include those modules and use them as ecmascript functions too? ^
*alextee[m] attempts
<singpolyma>A scheme module? Yes
<singpolyma>`var blah = require("some.scheme.module"); blah["some-proc"]();`
<singpolyma>Where the dots go where the spaces would to use module from scheme
<singpolyma>So `var track = require("audio.track");`
*alextee[m] uploaded an image: (37KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/aLLRtQVvQGhThIyczSQypDvX/Screenshot%20from%202022-04-05%2000-36-43.png >
<alextee[m]>amazing!! singpolyma thanks
<alextee[m]>er ignore the "hello" that was from the previous invocation
<singpolyma>If you have other questions about guile ecmascript I'm usually here and AFAIK know more than easily most people about it :)
<singpolyma>I should really write something for the manual about it, but haven't yet
<alextee[m]>singpolyma: neat! i saw in the manual that it said ECMAscript support needs a lot of work, is that still true? is it incomplete in some way?
<singpolyma>Uh. Well, it could use some love, but it depends on your goals
<alextee[m]>also, does guile have a way to auto-detect the language of the script so I don't have to add a dropdown to select?
<singpolyma>AFAIK the es5 syntax support is pretty complete
<alextee[m]>I mean it's mostly just invocations of my API so it should be fine.. unless the user wants to do some complex javascripty stuff
<singpolyma>The APIs are mostly the guile APIs with very few things to make it look like say the node stdlib
<singpolyma>And no es6 stuff
<singpolyma>So, it's a very valid ecmascript but if you call it "JavaScript" a node dev can't "just use it" for anything very big without learning
<singpolyma>I think there are some proposals/patches around about racket style #lang or extension based support, but I don't have a link on me
<alextee[m]>guile APIs and my own modules are more than enough to accomplish most things I guess, sounds good enough
<singpolyma>BTW, if you haven't seen them there are also out of tree lua and python for guile. I have played with the Lua a bit not the python yet
<alextee[m]>I saw that lua is "coming soon" on the website
<singpolyma>The Lua is a bit buggier than the ecmascript, but it's usable
<alextee[m]>would I have to compile guile myself with specific flags to enable those?
<singpolyma>Nope. Just include the modules for Lua in the guile load path
<alextee[m]>i can't really find any info how to do that XD will need some handholding to try it
<alextee[m]>but ecmascript and scheme are more than enough until python/lua are fully baked
<singpolyma>Can do elisp too, that's in tree ;)
<alextee[m]>I'll add a drop down between "elisp" "scheme" and "ecmascript" for now
<alextee[m]>and pass the selection to that code
<alextee[m]>hmm i wonder if there's a way to introspect available modules
<alextee[m]>to show embedded docs on that editor
<alextee[m]> https://www.gnu.org/software/guile/manual/html_node/Module-System-Reflection.html this probably
***sneek_ is now known as sneek
<dsmith-work>{appropriate time} Greetings, Guilers
<mwette>o/
<mwette>#lang support, work-in-progress: https://github.com/mwette/guile-contrib/blob/main/patch/3.0.8/load-lang.patch
<mwette>(use-modules (system base compile)) (add-lang-extension "py" 'python)
<mwette>then files that end in .py or file w/ first line "#lang python" should use that langauge (when installed); not confident it is robust
<civodul>mwette: oh, sounds nice!
<chrislck>\o/
<drakonis>mwette: that's really nice!
<mwette>ty
<stis>Hi guileres!
<drakonis>maybe it'll soon be time to rebrand guile as a language oriented programming language?
<lilyp>language oriented programming
<lilyp>programming oriented programming
<lilyp>We did it, we solved programming :)
<ft>Took us long enough. :)
***jackhill is now known as KM4MBG
***KM4MBG is now known as jackhill
<spk121>meta-objects, macros & programming oriented programming: MOM & POP
<mwette>spk121: building guile-gi; in gi-gtkdoc.scm I think (let ((f (tmpnam))) (mkdir f) ...) should be (let ((f (mkdtemp "/tmp/guile-gi-XXXXXX"))) ...) as tmpnam will be deprecated soon (I build guile with --disable-tmpnam)
<spk121>ok, thx
***sneek_ is now known as sneek