<ArneBab>would it be viable to implement an (ice-9 racket) with an interoperability layer to be able to run most racket code? ***alphor_ is now known as alphor
<nalaginrut>davexunit: what's the status of chickadee now ;-) ? <davexunit>nalaginrut: same it was as of the last release ***rubdos_ is now known as rubdos
***dje is now known as xdje
<joshuaBPMan_>Hello, I'm trying to solve a reddit daily programming in guile, just for fun. As a warm up exercise to that I'm trying to create a function that prints "1 2 3" via recursion and uses a closure. I'm trying to copy the guile info manual, but it doesn't seem to work for me. Here's my paste bin: http://pastebin.com/vPLbYYKD <davexunit>you've made a procedure that returns a procedure <davexunit>which is certainly not what you were trying to do <joshuaBPMan_>hmmmm. davexunit: Are you in #wordpress a lot? I feel like you've helped me out there before.... <janneke>also, the optional second parameter to display should be a port <joshuaBPMan_>hmmm. I'll have to read the info manual again. I feel like that was the example that they gave... <joshuaBPMan_>I was looking at 3.4.6 Example 1: A Serial Number Generator <joshuaBPMan_>There's a short example. I'll try looking at the code closer. <davexunit>there's probably about a dozen things weird going on in your code <davexunit>the only thing that makes it not work is the way you define the function <davexunit>if you took the parens away from the first instance of (1-3), it should work <joshuaBPMan_>hmm. I am a noob, so that's probably why it's soo odd looking. I really ought to read more about how to structure scheme code. <davexunit>calling it multiple times will do absolutely nothing <joshuaBPMan_>actually no. I can't remove the parenthesis from the first instance of (1-3) then it would be (define 1-3 (let) ....) <davexunit>joshuaBPMan_: also as janneke points out your call to 'display' is wrong <davexunit>you cannot pass a string as the second argument <davexunit>to display 'x' and then a space, you need 2 calls <davexunit>joshuaBPMan_: you're welcome. in the future, please avoid using pastebin.com. they do many bad things, including blocking tor users. <davexunit>and some people that could help you in this channel browse with tor <davexunit>you can call 1-3 multiple times and it will output "1 2 3 " every time <joshuaBPMan_>Your code must also have a closure in it as well. Is "named let" syntactic sugar that removed the need to write a lambda right after the let? <joshuaBPMan_>aka (let loop ((x 1)) ....) == (let loop (lambda (x 1) ...)) ? <davexunit>the lambda needs to be given a name so that you can call it again and again <joshuaBPMan_>OrangeShark: I don't need to I suppose. davexunit showed me how I can output numbers without it...It would be nice to know how to use closures, because they sound pretty awesome. <OrangeShark>joshuaBPMan_: Oh, I thought that was one of the requirements <davexunit>joshuaBPMan_: that 'inner' procedure *is* a closure <davexunit>the procedure '1-3' "closes over" the procedure 'inner' <OrangeShark>davexunit: I think joshuaBPMan_ wanted it to use a closure to keep track of the number like in the example they referenced in the guile manual <joshuaBPMan_>OrangeShark: I understand a closure is something like a static variable. All the variables in the closure keep their same values. <joshuaBPMan_>If I use just plain recursion w/o a closure I thought it would be harder. <davexunit>OrangeShark: okay, but a closure just doesn't make sense in this case. <OrangeShark>joshuaBPMan_: a closure is more like data that can be used by a function that was passed as an argument or returned by a function <joshuaBPMan_>So the named let is syntatic sugar for davexunit second peice of code that said (define (1-3) (define (inner x))) <OrangeShark>when that function was returned or passed an argument <OrangeShark>joshuaBPMan_: in davexunit's code, the state is passed through the recursion and not a variable outside the function <OrangeShark>the 3.4.6 example uses a closure to allow you to create functions with their own little memory which is the number it keeps track of <joshuaBPMan_>What I was trying to do was create a function that'll accept (number1 . number2) as input and output their lowest common factor or #f if it does not exist. My incomplete code is here: http://paste.lisp.org/display/342020 Essenitally I am trying to make factor a static variable...So it remembers it's value from the previous call. <OrangeShark>when you call (make-serial-number-generator), it creates a closure with `current-serial-number` and returns a function that references the closure. <OrangeShark>then you can call that function each time to increment that number which is unique to that function <Walakea>how does guile work together with C++ code? <joshuaBPMan_>You can try looking at the guile manual. I think it has a section about that. <spk121>Walakea: ffi interface is not good with c++. Also, since guile uses setjmp, using c++ exceptions can cause problems. <spk121>Walakea: or so I've heard. I've never tried it. <amz3>tho they are projects using c++ and guile <amz3>never heard of anyone trying but AFAIK Rust was built to be compatible with C <amz3>at the ABI level I think... not sure about that <random-nick>joshuaBPMan_: no unless the rust code exposes a C interface <random-nick>joshuaBPMan_: since guile only has a C Foreign Function Interface <spk121>hey all. If I can call (current-source-location) and (current-filename), it is possible to have a (current-procedure) procedure? <wingo>spk121: humm, good question... what would it do? :) <wingo>ACTION writes an "eval-in-sandbox" function <spk121>wingo: imagine it for a message in an assertion macro or a logging call. <wingo>spk121: what name do you give tho? i assume it evaluates to a name. <wingo>like how do you give a procedure a name that is used inside the procedure <wingo>when a procedure is a value that can many names or no name <spk121>wingo: dunno. :-) I know you can print a stack trace, so the moving up the stack trace to the first location with an associated procedure name? <paroneayea><ArneBab> would it be viable to implement an (ice-9 racket) with an interoperability layer to be able to run most racket code? <paroneayea>ArneBab_: well one problem is that Racket has so many languages <wingo>i really like racket's #lang thing <wingo>for example i was thinking in guix to be able to have the package.scm be a more stable API from guix -- in that case you might want to use a #lang guix-universe-package <wingo>spk121: it is an interesting question :) of course you can get that info at run-time. but the value is getting it at expansion time <wingo>but expansion-time is pre-optimization, and run-time is post-optimization... <wingo>dunno, i think you would need the expander to keep a kind of fluid value of what the current procedure name is. <wingo>and it would be somewhat limited, like loops would be in nested procedures <wingo>so they probably wouldn't have names <spk121>wingo: Well, logging is only valuable at runtime. Assertions are sometimes valuable at compile time. <spk121>wingo: anyway, I was just curious. <wingo>yeah sorry to not have a great answer :) <wingo>is the after-gc-hook just not getting called <thomassgn>What does the '%' in %variables mean? does guile care? and is there any resource I can reference to check for this? guile-beginner-9000 <spk121>thomassgn: in general % indicates that a thing is low level or internal <spk121>thomassgn: but, it is just a naming convention. <paroneayea>thomassgn: it is also used for dynamic / fluid things <wingo>yeah we need to write these up. unfortunately there's no canonical reference so people do whatever they want :) <paroneayea>but as spk121 said, it's just a convention... and a very vague one <paroneayea>wingo: I think maybe the naming convention I occasionally worry about the most is whether or not it's acceptable to put *? suffix on a boolean procedure argument <paroneayea>wingo: seems pretty common, esp with keywords... (define* (foo #:key bar?) ...) <paroneayea>but now we're using that both for predicates and boolean values <paroneayea>which is... hm, I'm never sure if it's great, though I do it sometimes too <wingo>clearly we need to embed ml into our naming conventions <paroneayea>wingo: my brother argues that scheme's use of *! and *? are code smells, because they betray that the system can't indicate those things for you... but he's much more of a type-y neat, and I'm much more of a scruffy, so it doesn't bother me :) <spk121>We can bring back reverse polish notation, for the win! <amz3>no guile gsoc idea page? <amz3>I don't have gsoc idea tho <janneke>mes compiled by mescc now runs scheme program that implements full scheme reader <janneke>previous target was running memory-dumped programs like '(cadr (cons 1 2))' ;-)