***ijp is now known as joe`
***joe` is now known as ijp
<dje42>While there's something to be said for staying in Scheme,I'm finding IWBN if I could set a gdb breakpoint to catch when "uncaught throw to ..." happens. Suggestions? <mark_weaver>dje42: I'm a bit confused what you're asking for. it's easy enough to arrange to get dropped into the Scheme debugger when an uncaught throw occurs. <mark_weaver>just pass #:on-error 'debug (the default) to 'call-with-error-handling'. <mark_weaver>more generally, you can set pre-unwind exception handlers. <mark_weaver>the thing is, if the error happens in Scheme code, it seems nicer to be dropped into a scheme debugger than a C debugger, no? <mark_weaver>I wrote before that the YeeLoong 8133 was now available at 590 €. Now I see that it's actually 540 €. <dje42>mark_weaver: I want to get dropped into gdb. E.g. gdb gdb+guile, run, foo, bar, baz, -> uncaught throw <dje42>I want to go up the stack into gdb and see the the code from gdb that calls into scheme. <mark_weaver>well, I don't know enough about GDB to know how best to arrange that, but Scheme code can call arbitrary C code, so. <dje42>Yeah, I can have the appropriate spot call a scheme-function-implemented in c. <dje42>Just wondering if there wasn't already such a beast. <mark_weaver>it can either be a scheme-function-implemented in C, or it can be a normal C function that is called via Guile's Dynamic FFI. <mark_weaver>you were wondering if there was already something that does what, exactly? <dje42>Guessing, and I don't know libguile *that* well, but <nalaginrut>dje42: you want to use GDB for debugging Guile? or use Guile for GDB debug script? <dje42>since it's intended to be embedded in other programs (written in C, C++) one might provide hooks that one can set a breakpoint on for various things thta one might want to set a breakpoitn on. <dje42>I want to use gdb for debugging a C program that uses libguile. [the program happens to be gdb, but that's secondary] <dje42>[for the cases where the problem is likely in the C code .... <dje42>obviously if the problem is likely to be in the Scheme code I'd rather use the debugger more suited to that ...] <mark_weaver>I guess you're looking for a Scheme procedure implemented in C, whose sole purpose is that you put a breakpoint in it using GDB? I don't know of any such thing. <dje42>That doesn't need to be its sole purpose, but that's an example. <mark_weaver>well, I suppose you could use any rarely-used C procedure in libguile :) <dje42>For the nonce, I can set a breakpoint on scm_throw and just keep continuing until I trip over the uncaught throw. <mark_weaver>dje42: it might be sufficient to put a breakpoint in 'scm_primitive_exit'. That gets called when there's an uncaught throw, but I'm not sure off-hand if it's called before or after unwinding the stack. <ijp>hmph, found a hidden assumption in an old proof of bird's <dje42>btw, this is just too much run. Writing scheme code that interacts with gdb. <dje42>too much beer too .... s/run/fun/ *dje42 is reading up on hooks <dje42>Hmmm, I was happy to see scm_take_locale_string (yay, I don't have to worry about freeing the input string!) but libguile/strings.c has a FIXME saying it may be deprecated, and there's no protection to ensure the input string is freed if there's an encoding error. <wingo>sounds like a tricky project :) <nalaginrut>BTW, I discussed green-thread to mark_weaver, he'd like a cooler design but need to make guile ports support non-block, which may take longer time <nalaginrut>since our current aim is AOT, I wonder it's the plan of 2015... <nalaginrut>though I can implement green-thread out of guile-core, I have to depend on epoll edge-triger <nalaginrut>it doesn't perfect as guile-core support non-block port, but it's way to go... <nalaginrut>but consider AOT will reduce the code execute time from 85% to 10%, it's more important for AOT I think <wingo>yes i think the wip-ethreads stuff is the way to go in the end <nalaginrut>mark hope all the ports could be non-block, which could be a time consuming work, but I have to say, if Guile has the feature, it's perfect to choose Guile for writing server things <nalaginrut>anyway, a lame actor-model based server for Artanis is worthy before our 2015-plan ;-P <jmd>What's the best way to get an enum-like thing in guile? <ijp>the api is rather more complicated than needs be, IMO <wingo>jmd: for the moment i would just use symbols... <jmd>wingo: That's what I have been doing. The problem is, if I mistype one, I have no idea, why the program doesn't work .... <nalaginrut>ijp: I confess it's not cool to use, some times I prefer (length (member i *some-enum-list*)) <jmd>What does cond return if none of its tests are true? <taylanub>"Also, to nitpick: DD is not "abusing C syntax"; it's a clever way of exploiting the flexible *semantics* of C's switch and loops." ... yeah, sure, "flexible" ... <ijp>it's certainly an abuse, either way <jmd>Why is there begin when let() does exactly the same thing ? <taylanub>jmd: Hrmm, (let () x y) is one character more than (begin x y). :P <dsmith>And the mighty power of the lambda is once again exposed. <ijp>jmd: well, for one, begin splices at the top level <ijp>if you used let-nil, you couldn't have a macro return multiple definitions <ijp>I like to think of 'begin' as being the primitive on which your let and lambda gets it's multiple expressions <ijp>you can get it starting from single expression lambda, but it's not as nice <ijp>(define-syntax begin* (syntax-rules () ((begin* exp) exp) ((begin* first rest ...) ((lambda (v) (begin* rest ...)) first)))) ; for the record <jmd>How do I check for the existence of a file? <mario-goulart>If you don't want race conditions, you simply operate on it and handle exceptions if operation fails. <jmd>mario-goulart: Yeah, you're right. I'll have to lookup how to handle exceptions. <Arne``>I have a horrible newbe-question, but anyway: How can I call <Arne``> eval-string with the lang keyword-argument? <Arne``>what works: (eval-string "(+ 1 2)") <Arne``>what breaks: (eval-string "(+ 1 2)" #:lang (current-language)) <jmd>Is there an easy way to set up a handler that does nothing? <Arne``>dsmith-work: That’s cool - thanks! *Arne`` would have needed that yesterday :) <mark_weaver>ijp: 'begin' doesn't just splice at toplevel. it splices in internal bodies as well. <mark_weaver>e.g. (let () (define (a) (b)) (begin (define (b) (c)) (define (c) (a))) (a)) is an infinite loop via 3 mutually recursive procedures a, b and c. that won't work with your 'begin*'. <mark_weaver>Arne``: confusingly, the 'eval-string' in the default namespace has a different API than the 'eval-string' in (ice-9 eval-string). To use the #:lang keyword argument, you need the latter. Does (use-modules (ice-9 eval-string)) (eval-string "1 + 2;" #:lang 'ecmascript) work for you? <dje42>I have a Guile naming convention question: Given an object created with make-foo, and accessors foo-bar and foo-baz, is there a reasonable common convention for naming the field setters? set-foo-bar! ? foo-set-bar! ? <civodul>or even better: avoid setters altogether :-) <civodul>Bigloo pretty much follows the conventions of object-oriented C <ArneBab_>mark_weaver: ah, yes. That works. Thanks! <dje42>I don't know if people have an opinion, but I'd like to take a survey: What should the name of the gdb command be that invokes a Guile/Scheme expression? guile? or scheme? Examples: <dje42>(gdb) guile (display foo) (newline) <dje42>(gdb) scheme (display foo) (newline) ***sethalve_ is now known as sethalves
<ArneBab_>mark_weaver: now I can paste wisp-code into the repl and still eval scheme code snippets. <ArneBab_>mark_weaver: how did you get forward with your better wisp parser? <mark_weaver>ArneBab_: that work's on hold for the moment. visiting family, and there are many other things for me to work on that compete with wisp for my attention :) <dje42>As in the gdb command to invoke python? Equivalent example: (gdb) python print "foo" <dje42>The argument to the command is passed to the corresponding interpreter as is. <wingo>ideally the command would simply be "eval" :) <dje42>Multi-line commands are supported (btw). <wingo>but guile sounds fine to me :) <ijp>mark_weaver: I had forgotten it spliced in internal definitions too, but it makes sense <dje42>gdb does have an "alias" command". e.g., (gdb) alias eval = guile <dje42>alas gdb already has an eval command. <dsmith-work>"python" is both the language and the implementation <dje42>Over time one can imagine more python implementations. <mark_weaver>there's already PyPy + CPython (not that I'm a Python fan) <dsevilla>honestly, I tried this one in racket, but it is not working in guile <nalaginrut>when I failed many times for my brand new sendmail module of Artanis, I finally realized I can't connect to smtp of google <amgarchIn9>Evening! This is niceto have (add-to-load-path (dirname (current-filename))). Is ther a way to derive a path from the *interpreter* location in the shebang line #!/path/to/custom/guile/build? <amgarchIn9>any prettier than this (use-modules (ice-9 rdelim)) (add-to-load-path (dirname (string-drop (with-input-from-file (current-filename) read-line) 2))) <wingo>yeah, i don't think there's anything there... <wingo>though we've been talking about relocatable installations, i guess that is the fix you want, yes? <mark_weaver>amgarchIn9: you can make the top of the script be a bash script, all within a SCSH-style block comment !# ... #! <tupi>amgarchIn9: (search-path %load-path "ice-9/redlim.scm") ? <amgarchIn9>I have a few custom modules that I use in my scripts in the same location as the interpreter. But nevermind. Explicit path is probably even better in this case. <tupi>amgarchIn9: I would rather use the above, using "yourmodulepath/yourmodulename.scm" <tupi>i would not do that this way but that's me ... <amgarchIn9>Linux-specific way: (add-to-load-path (dirname (readlink "/proc/self/exe"))) <taylanub>.oO( A rare proper usage of the term Linux. )