<galex-713>Hi, I did (use-modules (ice-9 readline)) and it says “no code for module […]” <paroneayea>galex-713: maybe you don't have readline support built into your guile? <galex-713>trying to make uninstall them apt-get install guile-2.0-doc <galex-713>paroneayea: I still see inconsistencies within doc :/ <frofroggy>Can GTK objects from a C program be exposed to Scheme without rewriting smobs or procedures that may be already implemented in guile-gnome? <frofroggy>I noticed the GType C API in guile-gnome but I wasn't sure if it's meant for consumption by other C programs when they are extended with Guile <frofroggy>Specifically, SCM scm_c_gtype_instance_to_scm (gpointer ginstance) seemed relevant <frofroggy>A practical example would be to expose the main GtkNotebook in GNUtrition 0.4 so that Guile scripts could use the guile-gnome Scheme API to add tabs for advanced meal planning procedures <didi>How do I redirect the standard error of a subprocess started with `system*'? <didi>I don't want its output. <fhmgufs>I must have asked that before, but don't remember the answer, how do I reload a module at the REPL? (reload-module (my great module)) doesn't seem to work. <galex-713>Why can’t a define (function) be made inside a let without a syntax error? <lloda>scheme@(guile-user)> (let ((a 1)) (define (x) 3) (+ (x) a)) <lloda>fhmgufs: you can do ,re (my great module) <galex-713>lloda: (let ((x 0)) (define (entry-sn-generator) (set! x (+ 1 x)) x)) While compiling expression: <galex-713>unknown file:1:0: no expressions in body in form (let ((x 0)) (define (entry-sn-generator) (set! x (+ 1 x)) x)) <fhmgufs>galex-713: Well, it doesn't make sense to just define something in a let environment. <davexunit>galex-713: you can't have *only* definitions in the body of a let <peterbrett_work>Yes, the problem isn't the presence of a define, it's the absence of any body expressions <fhmgufs>If you need x just for the function you should have the let in the body of it. <peterbrett_work>(define entry-sn-generator (let ((x 0)) (lambda () (set! x (1+ x)) x)) <peterbrett_work>fhmgufs: No, it only creates a definition in the current lexical scope IIRC <galex-713>that explains why we have to make it that complex <davexunit>(define (foo x) x) is short-hand for (define foo (lambda (x) x)) <davexunit>define may only be used at the top-level and as the very first expressions within the body of a lambda expression <fhmgufs>Is it normal, that Emacs indents the first argument of when and unless twice? <davexunit>fhmgufs: the first argument to when is intended to be on the same line <davexunit>which is why the indent is greater if you move it to a new line <davexunit>so that the body of the when can still be distinguished from the predicate expression <fhmgufs>Ah, and btw, is there a mode which does line breaks automatically? <fhmgufs>I mean respecting common coding style rules. <davexunit>where to insert line breaks is, to me, not something that a machine can do for me. <fhmgufs>I think I would find it useful to be able to just type without paying attention to formatting. <peterbrett_work>I suppose one of the problems is that with Scheme you can arbitrarily define new syntax that does things differently to what a mode might expect <peterbrett_work>However, I can see that people might reasonably like to use such a mode :) <davexunit>fhmgufs: but the formatting rules or so few. <davexunit>for new syntax, I tell emacs what the rules are <davexunit>(put 'with-texture 'scheme-indent-function 1) <paroneayea>gonna wrap up mudsync and do the release for the jam <davexunit>I didn't have the chance to hack on my game all weekend so I'm coming up a bit short <paroneayea>davexunit: sorry to hear it, though I'm still excited about your progress <paroneayea>I'm excited that I have live ability to replace things in the MUD while you walk around <paroneayea>I've got a nice simple protocol for handing off the state of one actor to another <paroneayea>so it builds a new actor, transfers state, then replaces it <paroneayea>and if you miss some state, whatever, you're live hacking I guess ;) ***dje is now known as dje42
<fhmgufs>Hi daviid, I have a guile-gnome question again! <fhmgufs>I want to set some arguments for a signal handler and there's a function for <fhmgufs>doing that called "gtype-class-create-signal". The problem is that I don't know <fhmgufs>how to pass arguments to that function for the param-types parameter. What's <fhmgufs>a <gtype-class> object? Values like <gint> or <gboolean> don't work here. <fhmgufs>Also, I'm interested in what the second value of the list I pass to #:gsignal means (normally #f) <fhmgufs>Maybe that's for setting the arguments? <daviid>fhmgufs: hello! I never defined signals myself, so this is not the part know very well, and I'll leave in a short while, will reconnect later. this said, I recommend you to look at the tic-tac-toe.scm example, which does exactly that: creating a new signal ... in gtk/examples <fhmgufs>I already know how to define signals thanks to you pointing me to that example before. :) <fhmgufs>I just want my handlers to accept parameters and therefore know what I have to pass to that function. <daviid>ah it was you, I wasn't sure, but yes I pointed to that example already <fhmgufs>daviid: That's not specific to signals, other functions for gtypes also need <gtype-class> as arguments. <fhmgufs>In C I also didn't know how to do that, so it's not very bad :) <daviid>fhmgufs: <gtype-class> is the super class of <gobject-class>, <gparam-class> and <gvalue-class> <daviid>so, for example <gtk-window>, <gtk-button, ... would fill the contract <fhmgufs>daviid: But I can't take <gint> or sth like that, right? <daviid>no, you can't create a signal upon tha class of integers <fhmgufs>I'll just try around later, no I'm afk for dinner, thanks for your help! <jmd>How can I convert a string into a scheme expression? <wingo>(call-with-input-string str read) <jmd>I don't understand the difference between eval, apply and call <davexunit>there is no 'call' procedure that I can find <davexunit>eval actually evaluates an expression. apply just makes a procedure call with an arbitrary argument list. <davexunit>jmd: oh, the C interface. well that's also another story entirely. <davexunit>that is just a way to call Scheme procedures from C code. <jmd>I have an expression, created with "read". How do I evaluate that expression? and pass arguments to it? <jmd>Isn't that what I said at the start :) <davexunit>eval evaluates an expression within an environment <davexunit>passing arguments is only relevant to a procedure call <jmd>Yeah the "environment" bit was one part which confused me. <davexunit>unless you are implementing a REPL or something. <jmd>So I want to pass a string to a program which should normally be an expression. Say "(> x 4)" and evaluate that expression, passing it the value of x. <davexunit>you'd have to create a module that has x bound <jmd>Hmm. I've never done that. Is it possible to create modules on the fly? <nalaginrut>fortunately, run script from C side is a proper case to use eval, and i think scm_current_module is enough? <jmd>This channel gets more like #perl every day. <nalaginrut>maybe it means one may get more confusing even after be answered... <nalaginrut>jmd: anyway, I think you may just use scm_eval_string without specifying environment by yourself <jmd>Then how would I pass x ? <jmd>How would I bind x to a value. <jmd>davexunit: nalaginrut seems to be of the opinion that is not necessary. <davexunit>it is necessary if you want to add bindings that aren't in the default environment <jmd>(define-module (list foo) #:export (x)) <davexunit>define-module is syntax for defining module files <jmd>which is the "procedural API"? <davexunit>that's a macro for defining variables that are exported <jmd>So which is the one I need? <davexunit>jmd: make-fresh-user-module will create a new module for you <davexunit>I always use ,apropos at the REPL to examine what's available <floor13>anyway to pipe that into less? I've tried $ guile -c ,a foo | less , but that gives me a quasiquote error <floor13>hm, guile | less and then typing blindly works, but I guess I just need to use tmux's scrolling <davexunit>floor13: you'd want to use the procedures that the ,a metacommand uses. <nalaginrut>guile -c '((@@ (system repl command) apropos) "module")' <nalaginrut>floor13: but I don't understand why you want to print it in terminal <nalaginrut>guile -c '((@@ (system repl command) apropos) "foo")' | less <floor13>ie inc search when piped into vim with :r! <nalaginrut>alright, seems we don't have good geiser alternative for Vim users <floor13>yeah, I guess I'm not gonna get lots of vim love here :P <davexunit>floor13: you should have a REPL running always for this purpose <davexunit>for example, geiser opens a REPL and talks to it over a socket <random-nick>a few weeks ago someone came in #emacs and ask if somebody is interested in renaming their guile-elisp commits to be changelog style <lfam>What does it mean when a variable's name starts with the % symbol? <lfam>I tried to find an answer in the Guile manual but I couldn't <lfam>What does this convention indicate? "Civodul wuz here"? ;) <lfam>I will start reading with that in mind <davexunit>or just plain ol' top-level global variables <davexunit>I shouldn't use constant because they are available for mutation <fhmgufs>(define a "Why is that") (define b "not working?") (string-join '(a b) " ") ? <davexunit>fhmgufs: '(a b) is very different from (list a b) <davexunit>'(a b) is a list containing the symbols a and b <davexunit>(list a b) is a list containing the values referred to by the names a and b, which are your strings. <fhmgufs>Oh, sorry, I already knew that, but just thought ... well, thanks! <lfam>davexunit: So, the %variables aren't "true" constants, since they could be mutated, but we don't mutate them in practice? <lfam>Whenever I get this code to actually work and submit it, I'm sure it will require many corrections :) <roelj>Is the 'procedure-source' function ever going to be implemented in Guile? <roelj>I used MIT Scheme, and it has a similar function called 'pp'. <stis>This is a good comment. I love how the ipython shell take advantage to source code information, as a result bkazingly fast bugfixing can typically be done <mejja>mit scheme keeps an approximation of the original code around so that you can pp compiled code <roelj>I would expect Guile to be able to provide the source code of a function I wrote in Scheme. <taylan>roelj: IIRC it's on the prospect <fhmgufs>I have a list and want to call a procedure with the members of that list as part of the arguments. <mark_weaver>roelj: out of curiosity, why do you want this? in the general case, with procedures that were generated by a macro, e.g. the constructor/accessor/mutator procedures created by a record type definition, it's not entirely clear what the "source" should be. <mark_weaver>roelj: e.g. what would you expect 'procedure-source' to return when applied to 'pipe-info?' from ice-9/popen.scm ? <roelj>mark_weaver: I don't know, let me have a loop at ice-9/popen.scm <roelj>mark_weaver: So, pipe-info is a record. I don't know what procedure-source should do with this.. probably return #f. <roelj>mark_weaver: But with something like: (define (say-hello) (begin (display "Hello!") (newline))) <roelj>(procedure-source say-hello) could return (begin (display "Hello!" (newline))) <mark_weaver>roelj: one could argue that the source code of 'pipe-info?' is on line 324 of srfi/srfi-9.scm <mark_weaver>we have macros expanding into macros into procedure definitions <roelj>Right, that makes things difficult <mejja>In MIT Scheme (pp pipe-info?) would pretty-print: (lambda (object) (and (%record? object) (eq? (%record-ref object 0) tag))) or some such.. <mark_weaver>roelj: are you looking for this for debugging purposes, or do you have some code that needs this to do its job? <mark_weaver>we save file/line/column information for procedures, and geiser can make use of this to bring you to the definition, although I don't know what it does in these difficult cases. <mark_weaver>the idea has been raised of saving copies of all the source code in our .go files, but I guess we never made a decision about that. <roelj>mark_weaver: I have a record type with a field that contains the procedure to execute (which is a function). I want to execute that function in a shell script. So I wanted to do that by getting the code of the procedure with (procedure-source that-function), then put that in a file. <mark_weaver>oh, well, that would fail to work more often than not. procedures typically have other procedures and other definitions that they need from the module they're in, etc. <wingo>you can give the procedure a separate property <wingo>possibly including the source <wingo>(procedure-property (lambda () #((foo . bar)) #f) 'foo) <wingo>i think it's documented but not very loudly :) <roelj>That had to sink in for a second. A ha. <wingo>(define-syntax-rule (define-with-source (foo . args) body ...) (define foo (lambda args #((source . '(body ...))) body ...))) <roelj>That makes it pleasant to define <wingo>(define-syntax-rule (define-with-source (foo . args) body ...) (define foo (lambda args #((source . (body ...))) body ...))) <wingo>then just (define-with-source (foo) bar baz) <wingo>(procedure-property foo 'source) => (bar baz) <wingo>it's well-defined but might not always be what you want :) <roelj>This is very interesting. Thanks a lot! <roelj>I need to play with it to fully grasp it I think <wingo>i agree with mark that we can't provide such a thing in genera <wingo>because it doesn't make sense with macros -- there's no natural stopping point <wingo>at which to say "this is the source" <wingo>and possibly no natural starting point either <wingo>at least, seems to me. but many bespoke solutions can work for many specific use cases <roelj>Indeed indeed. I hadn't considered more complex cases than procedural-style things.. <mark_weaver>roelj: also, even in the absense of macros, many procedures are not defined at the top-level, in which case they often rely on free references to lexical variable bindings outside of their bodies, in which case copying just the procedure definition to a file isn't going to work either. <roelj>mark_weaver: You could wrap them in a let-environment to provide for those variable bindings.. <davexunit>roelj: what good does that do? variables can be mutated. <mark_weaver>roelj: consider this: (define (make-counter) (let ((counter 0)) (lambda () (set! counter (+ 1 counter)) counter))) <mark_weaver>counter-a and counter-b are now two procedures, each with their own private mutable counter <mark_weaver>how could you write these to a file and run them in a separate process while keeping the desired semantics of a single counter, such that each procedure never returns the same integer twice? <mark_weaver>having said all of this, there's nothing stopping you from using something like wingo's 'define-with-source' macro above, with procedures that are specially made to be "self-sufficient" in a sense, such that their source can be sensibly copied to a file and run. <roelj>mark_weaver: You cannot. So yeah, you can't do everything with it, yet you can still do something in some cases. Clearly, we don't want a "maybe works" implementation in Guile.. <wingo>sometimes it stops me from making cool things tho! <roelj>mark_weaver: Now I actually wonder what MIT scheme will do with this.. :P <roelj>(pp counter-b) => (lambda () (set! counter (+ 1 counter)) counter) <mark_weaver>this kind of answer is helpful for debugging, but not something I'd want a real program to depend on to work. <mark_weaver>I would try hard to avoid writing a program in such a way that it depends on this kind of functionality. <davexunit>lots of newcomers come here and want to use things like 'eval' or whatever in strange ways <mark_weaver>yeah, that's why I so often get nosy and ask questions like "why do you need this?" ***micro` is now known as Guest28442
<wingo>i wonder if we could game simple web server benchmarks with something like 8sync <wingo>where you could accept a request, read off the data, and respond without blocking, and therefore avoid ever reifying a continuation <wingo>if the request and response are small enough it's possible <wingo>the kernel would be the one managing the tcp buffers <paroneayea>wingo: btw, I wanted to talk to you about 8sync and your port refactor's "buffering and prompts" stuff <paroneayea>mainly that you mentioned something about intelligently aborting to a prompt with the agenda and writing to (??) a port, and I wasn't sure what that would be like <wingo>paroneayea: you would call ((current-read-waiter)) <wingo>so it would be 8sync's responsibility to parameterize current-read-waiter appropriately <wingo>the default waiter would block by calling poll(2) on the fd <trough>Hello. Is guile able to take the place of bash scripts, invoking shell commands? <wingo>see system / system* for basics, open-pipe et al for pipes <ft>Some higher level glue to handle child processes would be nice, though. <paroneayea>and I'll try to hook 8sync up against it and we'll see if it works <trough>wingo: I didn't see a mention of system or open-pipe in the manual's scripting section. I wonder if I could suggest that somehow? <wingo>trough: sure, send an email to bug-guile@gnu.org -- that will make a ticket that we'll handle eventually <wingo>we are a little slow there currently but it will happen :) <wingo>of course if it's a patch to the manual or example text that's very welcome too :) <trough>I would have to run it by someone else first; I am quite a novice.