IRC channel logs

2013-11-11.log

back to list of logs

<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>it's best to avoid 'nil' unless you have no choice.
<madsy>thanks
<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)
<mark_weaver>s/so such/no such
<madsy>yeah
<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>morning guilers~
<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
<nalaginrut>and it's trivial for my program
<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>well, symbols is fine for that ;-)
<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?
<nalaginrut>I like this new stuff ;-P
<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.
<mark_weaver>where's 'scm_is_eq' by itself is just C '=='.
<madsy>right
<madsy>I just thought it was strange that symbols with the same string would also have the same SCM pointer
<mark_weaver>that's what the "interning" is all about.
<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?
<nalaginrut>cky: yes ;-P
<nalaginrut>but seems it's little faster than before
<nalaginrut>I mean compiling
<nalaginrut>maybe just my feeling
<cky>I'm too scared to touch master. Maybe I should brave it one day.
<nalaginrut>well, take it easy, you don't have to install
<mark_weaver>nalaginrut: "make clean" might be worth a try.
<mark_weaver>and maybe also rerun ./configure
<nalaginrut>mark_weaver: I tried, or it's error
<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
<mark_weaver>we do have something like that
<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.
<nalaginrut>yes we have
<nalaginrut>but exclude 'make clean'
<mark_weaver>actually, come to think of it, I doubt there'd be a need to rerun ./configure manually.
<nalaginrut>IIRC it'll run it automatically
<nalaginrut>but 'make clean' manually
<nalaginrut>ice-9/boot-9.scm:117:22: In procedure symbol->string: Wrong type argument in position 1 (expecting symbol)
<nalaginrut>anyone every done the compilation?
<nalaginrut>s/every/ever
<madsy>error: ‘scm_c_bind_keyword_arguments’ was not declared in this scope
<madsy>:-(
<madsy>Looks like I have to compile the latest guile version
<nalaginrut>madsy: what's your version? ;-)
<madsy>2.0.7
<madsy>The one that ships with Ubuntu raring
<nalaginrut>heh, I think you need 2.0.9
<nalaginrut>which is the best release at present
<nalaginrut>or you may try it from git
<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>yep
<madsy>I got 2.0.9 source downloaded. Just need to get the dependencies
<mark_weaver>madsy: apt-get build-dep guile-2.0
<madsy>mark_weaver: None of the dependency versions have changed since 2.0.7?
<mark_weaver>no
<madsy>Saves me from reading the README. Thanks :)
<mark_weaver>np :)
<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.
<madsy>hehe
<madsy>I'll mess around with it
<nalaginrut>I know nothing about windows, except games ;-P
<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.
<mark_weaver>I don't know precisely what the current status is.
<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.
<madsy>ok
<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.
<nalaginrut>ok done
<nalaginrut>after clean then reconfigure
<mark_weaver>nalaginrut: it's working now?
<madsy>Do I have to set --exec-prefix when installing guile in my home directory?
<nalaginrut>mark_weaver: yeah, it's working
<nalaginrut>well, I should try a test
<nalaginrut>GNU Guile 2.1.0.1346-4c906
<nalaginrut>mark_weaver: hmm...all passed
<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>I think just specify --prefix is enough
<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
<wingo>moin
<madsy>moin
<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
<wingo>hehe :)
<nalaginrut>wingo: I just compiled master, and all tests passed ;-P
<wingo>nalaginrut: nice :)
<nalaginrut>but seems something wrong in benchmark
<wingo>which benchmark?
<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
<nalaginrut>wingo: benchmark-guile
<madsy>wingo: thanks
<nalaginrut>maybe it's trivial
<wingo>nalaginrut: want to make a patch? :)
<nalaginrut>wingo: sure, if I can figure out what it is ;-P
<nalaginrut>wingo: is bytevector similar with uniform-vector?
<nalaginrut>actually I mean 'equal' with
<wingo>uniform vectors (srfi-4 vectors) are implemented on top of bytevectors
<nalaginrut>ok thanks
<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?
<madsy>#define and #undef ?
<wingo>haha, yep ;)
<wingo>terrible
<wingo>see "Function Snarfing" in the manual
<wingo>for the use case
<madsy>:D
<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
<wingo>it defined s_scm_foo
<wingo>so you do
<wingo>#define FUNC_NAME s_scm_foo
<wingo>{
<wingo>...
<wingo>}
<wingo>#undef FUNC_NAME
<madsy>Ah, so I probably didn't follow the function name convention
<wingo>well that s_scm_foo is the scheme name
<wingo>the one in quotes
<wingo>"foo-bar-baz"
<madsy>right
<madsy>Doesn't seem to have declared anything with s_. Here's one of my .x snarfed files: https://gist.github.com/Madsy/7410057/raw/44ed5266e5fdc4a6e3d635e78cb5b682aabaf3e9/gistfile1.c
<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>hum
<wingo>could it be that somehow the SCM_DEFINE thing declares it? yes i think that's it
<wingo>const char s_##name = ...
<madsy>Okay, so then I need a #define and #undef inside the function body itself
<wingo>yep
<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>you're probably safe :)
<madsy> https://gist.github.com/Madsy/7410120
<wingo>usually we put the #define before the opening brace
<madsy>ah, ok
<wingo> http://git.savannah.gnu.org/gitweb/?p=guile.git;a=blob;f=libguile/pairs.c;h=1a3c5a18cd8a1ef435342bb6bfc1906d1f4822d5;hb=HEAD#l100
<wingo>^ example
<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
<wingo>np :)
<madsy>Hm, yeah. I'm thinking maybe I should just wrap low-level OpenGL to scheme, and implement the high-level interface there.
<wingo>you didn't like figl?
<wingo> http://wingolog.org/archives/2013/02/16/opengl-particle-simulation-in-guile
<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
<wingo>ah
<madsy>It sounds silly, but I have my reasons
<wingo>ok :)
<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?
<wingo>0 i think
<wingo>terrible.
<madsy>:D
<madsy>Sorry for finding all your bugs/limitations ;-)
<wingo>i prefer to get around them by using scheme as much as possible :)
<nalaginrut>wingo: I sent the patch to fix benchmarks
<wingo>cool, tx
<nalaginrut>;-)
<madsy>wingo: Seems like I should use SCM_ARGn instead of 0, but it's defined to 0 :)
<wingo>right, do what you like :)
<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
<madsy>haha
<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>see the Makefile.am
<TaylanUB>OK
<nalaginrut>so much 90s things
<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
<wingo>that would be odd
<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>yep
<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
*wingo looks
<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> http://git.savannah.gnu.org/cgit/guile-gnome.git/tree/glib/gnome/gobject/Makefile.am#n40
<wingo>then you have to install taht text file and add it to a list at some point http://git.savannah.gnu.org/cgit/guile-cairo.git/tree/cairo.scm#n38
<madsy>Woah.. seems complicated
<wingo>yep
<wingo>unfortunately
<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> http://git.savannah.gnu.org/cgit/guile-gnome.git/tree/common.mk#n50
<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 :)
<dsmith-work>Hey hey
<madsy>hey dsmith-work
<madsy>Awesome. My guile API works now
<wingo>neat :)
<madsy>OpenGL in a second thread. Two threads with one OpenGL context each share a renderbuffer
<wingo>really!
<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.
<wingo>cool
<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>right
<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>A GUI inside OpenGL that is
<davexunit>why do need 2 threads to do that?
<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?
<davexunit>I see.
<madsy>In my case, my application hosts guile, not the other way around
<davexunit>embedding vs extending.
<madsy>Btw, what happens when an exception is thrown to toplevel? Does the debugger kick in?
<davexunit>the game loop catches *all* exceptions.
<madsy>I was thinking in general. If you have an uncaught exception :)
<civodul>Hello Guilers!
<madsy>Hey civodul
<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
<cky>Lulz.
***sneek_ is now known as sneek
<dsmith-work>wingo: Hah!