IRC channel logs


back to list of logs

<dokma>If I'm running some guile code using scm_c_eval_string how do I pass variables to it from C++ ?? Ints and strings in particular.
<dokma>Not literals, but stuff that comes from variables.
<ane>you need to define things using scm_c_define etc
<ane>i.e. if you want to eval (+ 1 a) you need to define a first
<dokma>ane: got it
<dokma>ane: is there any particular api shorthand to define a list?
<unmatched-paren>dokma: scm_list_1(elem1), ..., scm_list_5(elem1, ..., elem5), and scm_list_n(elem1, ..., elemN, SCM_UNDEFINED)
<dokma>damn... how do I not see this stuff
<lloda>the doc is generally good, but indices cannot replace search. I'm guilty of grepping the guile source when i need examples of something being used
<dokma>So I use scm_from_utf8_string(argv[0]) to create an SCM C object. Now, if I want to use this object in libguile I need to be able to reference it. How do I assign this SCM object to a symbol?
<dokma>So for example:
<dokma>assign the above created object to a symbol scm_argv;
<dokma>scm_c_eval_string("(display scm_argv)");
<dokma>I lack this basic plumbing as you can see.
<dokma>I'll just have to carefully read the entire Guile manual.
<dokma>scm_make_variable ??
<dokma>Hmmm... scm_make_variable doesn't take any sort of a string to create a symbol with the given value.
<dokma>What I'm basically looking for is to do (define scm_argv C_STRING_HERE) from C.
<dokma>ane: ^^^
<dokma>unmatched-paren: ^^^
<ane>you need to first create the SCM object, i.e. a boxed guile value from your string. then you need to define it to a symbol
<ane>creating a SCM from a string is the from_utf8_string thing, then scm_define to bind it to a symbol: scm_define("scm_argv", scm_from_utf8_string(argv[0]))
<ane>that might be scm_c_define, not scm_define
<dokma>Yup, that's it
<unmatched-paren>dokma: sorry, i can't help in general with the guile c api, i just remembered seeing those scm_list_N functions in the manual once :)
<dokma>unmatched-paren: thank you for your time! ane got it.
<dsmith-work>Morning Greetings, Guilers
<mwette>dokma: with scheme-bytestructures and guiles (system foreign) you could create access definitions for variables, from Guile. nyacc's ffi helper does somehting like that. see here for "extern int x;" :
<mwette>to read the var from scheme (x), to write (x 1)
<lilyp>dokma: you can also do this without a define
<lilyp>SCM s_display = scm_c_lookup("display");
<lilyp>SCM mystring = scm_from_utf8_string("Hello, world!");
<lilyp>scm_call_1(s_display, mystring);
<lilyp>note that instead of scm_c_lookup you might want to use modules, but that's not adding much difficulty
<stis>Hello guilers!
<stis>Anyone playing with ChatGPT?
<stis>hey hoo anybody coding?
<gnucode>stis: want a coding challenge?
<gnucode>yes I am aware that I misspelled "mispelling".
<stis>misspelling should be a solved problem no?
<stis>is there any C libraries out there that will excell at this task?
<stis>gnucode: ^^
<dsmith-work>Compilers are getting better at it. "I don't see 'foob' anywhere, perhaps you meant 'foo'?"
<stis>Aspell Hunspell Enchant
<stis>I'l go for aspell
<stis>do we have a scheme wrapper for aspell?
<gnucode>stis: I am coding for guix. The guix developers may not want me to add a new dependancy.
<stis>make sure that they think so first then, but ok a spell checker
<civodul>gnucode: Guix has "did you mean X?" kind of hints; the core of the implementation is 'string-closest' in (guix ui)
<civodul>(Levenhstein's distance essentially)
<civodul>Levenshtein, even
<civodul>"did you mean 'Levenshtein'?"
<stis>You could ask ChatGPT: write a spell checker in scheme that implements suggestions of corrections using the levenstein distance
<stis>works for me
<dthompson>I once wrote a (poorly implemented) version of levenshtein distance that output not a number, but the series of operations for transforming one string into another. was kind of neat.
<stis>This was a fast and fun spell checker:
<stis>One can then refine that. Gosh with ChatGPT we will enter a new era with much higher productivity amongs the coders
<dthompson>I'm wary of AI tools like this being truly beneficial.
<stis>Well If you learn to master it you will be very productive. It's a truly amazing thing if you know how to state the right questions and get you boiler plate to get started
<stis>it's a level up from stack overflow
<stis>Of cause you need to understand what you are doing so this will empower the skilled ones the most
<stis>If you know for example that in order to solve issues with precition, you can look for beter number types in stead of clever schemes and used ask the bot
<stis>and you will get C code that you can make use in a red second
<stis>and that code will be easy to maintain
<stis>If you did not know this you may try to use clever techniques that makes maintaining that code a nightmare
<stis>this is quite quick with stack overflow as well though.
<stis>Think of ChatGPT as a much improved search feature of stack overflow
<stis>gnucode: ^^
<gnucode>civodul: oh thanks! I'll use that instead!
<gnucode>civodul: is string-closest exported by guix ui? doesn't seem like it...
<stis>@@ /me hides
<unmatched-paren>stis: Unfortunately for us, the "Open" part of "OpenAI" appears to be mockingly ironic. :(
<civodul>gnucode: it's exported by (guix utils) actually
<gnucode>ok. thanks
<unmatched-paren>That raises an interesting "reverse Copilot" question, actually: would that code's copyright belong to the person who asked ChatGPT to write it? I suspect that's an easier question than the Copilot one, but still.
<stis>I find the storytelling and poetry part of ChatGPT the most yoyful
<stis>unmatched-paren: check out this speculation, I know it is happening now as people in my twitter feed is using it to troll opponents
<stis>They brag about how they ask the ChatGPT to find errors in the opponents argument
<stis>then copy paste the result. Just matter of days or weeks before they aoutomate that behavior.
<unmatched-paren>stis: Apparently ChatGPT rather likes the co-founder of the company that created it :P
<stis>unmatched-paren: Personlly I am a bit lax to his persona and dont mind people bashing or hailing
<unmatched-paren>Interesting how it doesn't mention the unbanning of neo-nazis or Musk's posting of that Paul Pelosi attack conspiracy theory, but we're getting a bit offtopic here :)
<unmatched-paren>(it would be funny if one of those bots were told to reply to that post, though ;P)
<stis>But the thing is that the good outcome is not certain and my main point is actually that to much freedom and you get too much bad actors that will ruin the experience or destroy countries
<stis>seams to happen already :-(
<stis>What do they say, when the truth comes out the lye has traveled around earth 10 times
<stis>unmatched-paren: Technically speaking bot wars will be very interesting to watch