<mark_weaver>there are a number of special values you could use, e.g. SCM_UNSPECIFIED, SCM_UNDEFINED, but if the variable in question can never hold a boolean, SCM_BOOL_F is a good choice. <mark_weaver>the existence of 'nil', which conflates the concepts of false and the empty list, is a *major* problem when trying to integrate with code written in languages where there is so such conflation (e.g. modern scheme) <madsy>In the C API, how do I compare a keyword to a string? Do I have to convert it to a symbol first? <madsy>Or maybe it's better to create a constant symbol and then compare that to the symbol? <nalaginrut>madsy: I use string->symbol then compare, but I don't know if it's the best way <madsy>nalaginrut: You convert the keyword to a symbol and then compare the two symbols? <nalaginrut>oh, keyword? yes, I converted ,but as I said, I don't know if it's the best way <madsy>Maybe I should just use symbols instead of keywords <nalaginrut>if you don't try to parse args, why you choose keyword? <madsy>That's what I'm contemplating :) <madsy>I just need something like: (gl-clear 'gl-color-buffer-bit 'gl-depth-buffer-bit) <madsy>I guess symbols would be better in this case <madsy>Now I have to figure out how optional parameters work. <nalaginrut>madsy: do you want to parse the optional params manually? <madsy>Well, I need access to the parameters from the C interface, so I don't think I have much choice <mark_weaver>madsy: if you are looking to match against a fixed keyword or symbol, then use scm_from_utf8_symbol or scm_from_utf8_keyword during initialization to create a global constant to compare against using scm_is_eq. <madsy>mark_weaver: eq? Is that right? Not eql or equal? <mark_weaver>madsy: to easily define procedures from C that take possibly optional keyword arguments, see 'scm_c_bind_keyword_arguments' <madsy>Ah, great stuff. I was looking for a function like that <mark_weaver>madsy: yes, that's right. because symbols and keywords are interned, you can use 'eq?' to compare and that's the same as comparing the strings. <mark_weaver>note that 'scm_c_bind_keyword_arguments' is very new. added in 2.0.9, iirc <madsy>Okay. So if I make some global SCMs for symbols and keywords, do they have to be permanent objects? <madsy>Either that or bound to toplevel <mark_weaver>madsy: they don't have to be permanent object, but it's a nice optimization since running 'scm_from_utf8_symbol' and 'scm_from_utf8_keyword' requires a hash table lookup. <madsy>I just thought it was strange that symbols with the same string would also have the same SCM pointer <madsy>But I guess it makes sense, since they are immutable. symbols and places are separate. <mark_weaver>this is the case in any lisp system, right from the beginning. <madsy>Ah, I understand optional arguments now. It's just N extra parameters set to SCM_UNDEFINED if they're not bound. <mark_weaver>exactly. btw, 'SCM_UNBNDP' in the conventional way to test whether something is SCM_UNDEFINED. <cky>madsy: *The* defining quality of a symbol is that it's interned (gensym and other uninterned symbols notwithstanding---those are anomalies ;-)). <cky>Interning is the bees' knees, for items that have a finite quantity and are immutable. <cky>I make it a point to know what is guaranteed to be interned, and exploit accordingly. For example, all string literals in Java are interned, and all class objects and enum values are effectively interned. You can compare them all using ==. <cky>(I mention Java because I use Java a lot in my day job, and I know it very well.) <cky>What I mean by "all string literals in Java are interned". Suppose you have a method: public static String helloWorld() {return "Hello, world!";} <cky>assert helloWorld() == "Hello, world!"; // this expression is always true, no exceptions, even if you're calling helloWorld from a different class. <cky>Likewise, if you have a Scheme function like this: (define (hello-world) '|Hello, world!|) <cky>(I'm using R6RS/R7RS syntax for symbols with arbitrary characters, not the funky Guile syntax.) <cky>then, (eq? (hello-world) '|Hello, world!|) is always true. <madsy>cky: Yeah I just didn't think about immutability right away <madsy>cky: And yes, hooray for snarf ;-) *nalaginrut still suspect that something was halted while compiling eval.go... <cky>nalaginrut: Is this on the RTL? <cky>I'm too scared to touch master. Maybe I should brave it one day. <dje42>I always wished it was s.o.p. for projects that use autoconf to have a "reconfigure" makefile rule: sh config.status --recheck && sh config.status <dje42>[probably need an rm config.cache in there too] <mark_weaver>our build system is pretty good, but not perfect. occasionally when there are major changes (like switching from one VM to another), make clean is needed. <mark_weaver>actually, come to think of it, I doubt there'd be a need to rerun ./configure manually. <nalaginrut>ice-9/boot-9.scm:117:22: In procedure symbol->string: Wrong type argument in position 1 (expecting symbol) <madsy>error: ‘scm_c_bind_keyword_arguments’ was not declared in this scope <madsy>Looks like I have to compile the latest guile version <madsy>The one that ships with Ubuntu raring <mark_weaver>madsy: yes, I mentioned it before, but perhaps you missed it: 'scm_c_bind_keyword_arguments' is very new. it's only in the most recent release, 2.0.9. <madsy>I got 2.0.9 source downloaded. Just need to get the dependencies <madsy>mark_weaver: None of the dependency versions have changed since 2.0.7? <madsy>Saves me from reading the README. Thanks :) <madsy>By the way, are the dependencies the same for Windows? <madsy>And does Windows support all the features Linux does, including threading? <madsy>My code is soon mature enough to test with a cross-compile <mark_weaver>sorry, I don't know. I'm fairly ignorant of Windows, and happily so. <mark_weaver>I know that we try to support compilation with mingw. I know there's been work to fix things up in 2.0 on mingw. <madsy>mark_weaver: Ouch.. if 2.0.x doesn't support Windows, I'm in trouble <madsy>My audience is on Windows. I was sure guile supported that OS.. hm. <mark_weaver>well, if it doesn't quite work, it's not far from working, let's put it that way. <mark_weaver>it's mainly that we need more help in that area. it's absolutely a priority for us to make sure that guile works on windows. <madsy>Do I have to set --exec-prefix when installing guile in my home directory? <madsy>How can I set a suffix for my lib directory? Do I have to set --libdir with the absolute path? <madsy>I have 64-bit libraries in $HOME/lib64 <madsy>Pesky to notice that error after building and installing <nalaginrut>for most of the situations, you just try ./configure is enough <madsy>nalaginrut: I set -exec-prefix just in case. I need everything in my home directory :) <madsy>Not very fond of installing stuff in /usr/local <madsy>Suggestion for an enhancement: scm_keyword_arguments_flags in keywords.h could need an enum for "no flag" <madsy>Since int-to-keyword in C++ requires a cast <wingo>dunno, I would think there are many more things we would change if we wanted to be more c++-friendly, when the real solution is a complete wrapper I think <wingo>and in the "real solution" it doesn't matter as no C value would make it out to C++, except inside the wrapper <wingo>perhaps i am missing some context though <madsy>Eh, what.. I said int-to-keyword. I meant int-to-enum, of course. <madsy>Sleep deprivation for the win <nalaginrut>wingo: I just compiled master, and all tests passed ;-P <wingo>i did not run the benchmark thing <madsy>scm_assert_smob_type() is used to check smob types. But how do I check for built-in types? SCM_ASSERT() ? SCM_ASSERT_TYPE() ? <wingo>usually you use SCM_VALIDATE_FOO from validate.h <wingo>nalaginrut: want to make a patch? :) <nalaginrut>wingo: is bytevector similar with uniform-vector? <wingo>uniform vectors (srfi-4 vectors) are implemented on top of bytevectors <wingo>they are bytevectors with an additional tag indicating "print me in units of u32" for example <wingo>you can use bytevector ops on them. <madsy>Some SCM_VALIDATE_xxx macros seem to depend on a define named FUNC_NAME instead of taking the name as a parameter. How am I supposed to set the function name? <wingo>see "Function Snarfing" in the manual <wingo>actually this is not explained very well at all in the manual <wingo>i think SCM_VALIDATE uses SCM_ASSERT, so maybe that's the thing to do <madsy>Yeah, I am snarfing already. Does guile-snarf somehow make this easier? <wingo>well it defines a symbol with the function name <wingo>if your c function is scm_foo <madsy>Ah, so I probably didn't follow the function name convention <wingo>well that s_scm_foo is the scheme name <madsy>That's when using SCM_DEFINE to declare new guile procedures <madsy>But if all it needs is the scheme function name as a string, I'll do it explicitly <wingo>could it be that somehow the SCM_DEFINE thing declares it? yes i think that's it <madsy>Okay, so then I need a #define and #undef inside the function body itself <wingo>quite silly, but it is how we do it currently <madsy>Okay, that seems to work? Hopefully it won't blow up in my face :) <wingo>that's how all of libguile does it <wingo>usually we put the #define before the opening brace <wingo>much better btw to implement a function like the one you show there in scheme <madsy>Again, thanks for your help. You guys are the most patient developers I've run into :-) <wingo>the default arg initializers for keyword arguments are really nice in scheme <madsy>Hm, yeah. I'm thinking maybe I should just wrap low-level OpenGL to scheme, and implement the high-level interface there. <madsy>That wouldn't work well with glfw3 which I'm using for window managment <madsy>I'm embedding guile, not the other way around <madsy>It sounds silly, but I have my reasons <madsy>Uh, so I have a function which only has varargs and keyword/symbol pairs. What do I pass on as "pos" to SCM_VALIDATE_ then? <madsy>Sorry for finding all your bugs/limitations ;-) <wingo>i prefer to get around them by using scheme as much as possible :) <madsy>wingo: Seems like I should use SCM_ARGn instead of 0, but it's defined to 0 :) <TaylanUB>How do we make changes to psyntax(-pp).scm ? Is there some tool to generate the -pp one from the normal one after making changes ? <wingo>that advice was written in the 90s <wingo>TaylanUB: you just edit psyntax.scm, and the build takes care of the rest <wingo>it can be tricky depending on what you're doing tho <wingo>we're getting to the 2010s, slowly but steadily :) <madsy>scm_out_of_range_pos seems to be broken in 2.0.9 <madsy>While scm_out_of_range works <madsy>Might be a bug with my code of course. But my function is pretty simple <wingo>are you passing an inum for the pos? <madsy>I passed SCM_ARGn, aka 0. Was that incorrect? <wingo>that function takes an SCM as the last parameter <madsy>Ah. Apoligies for the false warning then <madsy>Serves me right for grepping in the dark for the right function :) <madsy>Another weird thing: my docstrings don't show up for my C scheme procedures. What's up with that? <madsy>Geiser just says: ((guile-user): texture-create ...) <wingo>yeah that's an issue we have not solved nicely <madsy>Other than that, my code works surprisingly well. <wingo>you have to generate .doc files, assemble them into a texi, then use makeinfo to make a text file <wingo>basically what you need is texinfo, rendered to text, as a file, known to guile <wingo>how you get that format is a mess from C <wingo>in scheme of course it works for free :) <madsy>The snarfing doesn't help here? <wingo>so there are two parts of snarfing <wingo>one is to make the .x files you include in the c file <wingo>the other is to make .doc files <wingo>we don't have a properly packaged nice toolchain for doing the .doc thign <wingo>the only outside-of-guile project actually getting their docstrings available to guile that i know of is guile-gnome <wingo>perhaps we should do something else there... <madsy>There is no guile tool for the doc snarfing? "guild doc-snarf" is for scheme files only? <wingo>that's what guile-gnome does, fwiw <wingo>i think we used to have a doc snarfing tool but it was brittle and felt to be unsupportable <wingo>but that was a long time ago, before my time <wingo>it would be better to have a guild tool to do it <wingo>i don't know what guild doc-snarf does :) <madsy>Awesome. My guile API works now <madsy>OpenGL in a second thread. Two threads with one OpenGL context each share a renderbuffer <madsy>So the guile thread does all the rendering and calls glFlush when it should be displayed on the main thread <wingo>how do you synchronize between the threads? <wingo>it doesn't get you parallelism, does it? <madsy>A mutex and condition variable <davexunit>when I read about sharing GL context between threads, it seemed to be an unoptimal solution. <madsy>wingo: Not any more parallelism than a single context, no. <madsy>Or, well. To some extent it does, but I don't take advantage of it <madsy>You can get some extra parallelism out of it by loading textures and stuff asynchronously <wingo>ah they have one context each <madsy>I only have this setup to make my application more crash proof <wingo>for some reason i thought you meant one context total <wingo>yes in that case you can do fun things with fbos <madsy>If my scheme thread freezes, I can cancel the thread and still retain state <madsy>I can also ignore the scheme framebuffer totally and render something entirely different on the main thread <madsy>I plan to make a GUI for developing games/demos. So I can switch between displaying the GUI and the scheme framebuffer. <madsy>As I said, to make this more crash proof. If I cancel the scheme thread, I can still display some other graphics <madsy>Or if the scheme thread times out (on the condition variable) <wingo>cancelling threads is quite tricky, as you probably know... <madsy>And I have some other latency sensitive stuff I don't want to do from Scheme, like filling the audio buffer <davexunit>for guile-2d, I make things more crash-proof by simple handling exceptions that are generated within the game loop. <madsy>davexunit: That works fine if you only use guile as a standalone <davexunit>when an exception happens the game is paused and the developer can view the backtrace, fix the error, and resume the game. <davexunit>madsy: oh are you extending existing software with guile? <madsy>In my case, my application hosts guile, not the other way around <madsy>Btw, what happens when an exception is thrown to toplevel? Does the debugger kick in? <madsy>I was thinking in general. If you have an uncaught exception :) <cky>madsy: I agree that wingo is very awesome and nice to be around. :-) <cky>wingo: We need to meet up again, to do more keysigning. It seems a few months after we met up, you revoked your key. :-P <wingo>hey, i can still be grumpy and gruff :) <wingo>cky: haha, yeah i forgot my passphrase! <wingo>after printing the fingerprint on a business card, of course that's what i would do... <cky>Well, we're all human, but you handle it a lot better than most developers I know. Also, bummer about the password. :-( <cky>s/password/passphrase/ <wingo>maybe i should have filed an FOIA request for it ***sneek_ is now known as sneek