00:02 (quit) swartzcr: *.net *.split 00:02 (quit) cataska: *.net *.split 00:02 (quit) sethalves: *.net *.split 00:02 (quit) jamessan: *.net *.split 00:06 (join) swartzcr 00:06 (join) cataska 00:06 (join) sethalves 00:06 (join) jamessan 00:49 (quit) jrslepak: Quit: What happened to Systems A through E? 01:02 (join) Fare 01:09 (quit) mithos28: Quit: mithos28 01:15 (join) nilyaK 01:42 (quit) jeapostrophe: Ping timeout: 252 seconds 01:44 (join) Skola 01:53 (quit) yoklov: Quit: computer sleeping 02:23 (join) mithos28 02:34 (join) fftb 02:43 (quit) fftb: Ping timeout: 250 seconds 02:44 (join) fftb 02:57 (quit) nilyaK: Quit: Leaving. 03:04 (quit) fftb: Ping timeout: 250 seconds 03:10 (quit) mithos28: Quit: mithos28 04:12 (join) vkz 04:45 (quit) dspt: Ping timeout: 260 seconds 04:45 (join) dspt 04:56 (quit) Skola: Quit: Lost terminal 05:02 (join) mye 05:05 (part) lewis1711 05:31 (join) neilv 05:31 (quit) neilv: Changing host 05:31 (join) neilv 05:46 (join) MayDaniel 06:10 (quit) MayDaniel: Read error: Connection reset by peer 06:27 (join) fftb 06:31 (join) malkomalko 06:32 (join) rn_ 06:34 (join) rostayob 06:36 rn_: hello, community! I have a question. If we look at this http://groups.google.com/group/racket-users/browse_thread/thread/1fe13354bb641ae3/3389f195d637878e?lnk=gst&q=euler4e#3389f195d637878e we will se that it's recommanded to use (nested) define instead of let in this example. So, my question is: when to use nested define, and when to use let? 06:36 rudybot: http://tinyurl.com/7aggvek 06:38 neilv: rn_: it is a matter of personal preference. seems like more of the core racket developers are using internal define. seems like other people coming from scheme tend to use let 06:39 rn_: but felleisen said that define is faster? 06:42 (join) ambrosebs 06:42 (quit) ambrosebs: Client Quit 06:43 (join) realitygrill 06:43 neilv: he did? 06:43 rn_: yes, look at the last post 06:43 rn_: http://groups.google.com/group/racket-users/browse_thread/thread/1fe13354bb641ae3/8ac2c9d406cc10c5?lnk=gst&q=spirit+of+racket#8ac2c9d406cc10c5 06:43 rudybot: http://tinyurl.com/7os4dw6 06:44 neilv: looks to me like his change to from let to define was gratuitous, and that his performance improvement was to make palindromic use strings rather than lists 06:46 rn_: oh, so! i didn't notice the difference between the fuction palindromic in the first and last post 06:46 rn_: thanx 06:47 neilv: this is a new way in which internal define confuses people rather than helps them :) 06:47 rn_: you don't like internal define? 06:48 neilv: i don't have a strong argument against it. and it can make example code look more accessible to people who do not know racket at all yet 06:49 rn_: when is then recommandedto use the 'local' construct? it's unclear to me. 06:49 neilv: i don't use "local" either 06:52 neilv: you could try searching the email list for when to use internal define vs. local. i'm pretty sure it's been discussed recently 06:54 rn_: i've just found this: http://groups.google.com/group/racket-users/browse_thread/thread/3e934b513e018522/0505084b2327d39c?lnk=gst&q=local+define#0505084b2327d39c 06:54 rudybot: http://tinyurl.com/7ph7duf 07:01 neilv: http://www.ccs.neu.edu/home/matthias/Style/style/Choosing_the_Right_Construct.html#%28part._.Definitions%29 07:01 rudybot: http://tinyurl.com/7e4nqv9 07:02 neilv: that's all that i see matthias' style gude for core racket developers says about internal define 07:02 bremner: hmm. Not a super compelling reason ;) 07:03 rn_: i agree 07:08 (quit) djcb: Remote host closed the connection 07:08 (quit) vkz: Ping timeout: 276 seconds 07:09 neilv: i think there's been more arguments for it, but you'd have to search the email list 07:12 neilv: i don't like searching the email list because there are several different archives of it, so if i just go to google, i end up seeing the same threads over and over, for copies on different sites of varying ugliness 07:12 (join) vkz 07:13 bremner: is it on gmane? 07:13 neilv: it's everywhere 07:13 (join) RacketCommitBot 07:13 RacketCommitBot: [racket] plt pushed 4 new commits to master: http://git.io/HwcxdQ 07:13 RacketCommitBot: [racket/master] macro-debugger: internal debugging improvements - Ryan Culpepper 07:13 RacketCommitBot: [racket/master] macro-debugger: fix parser for local-actions in mod pass 2 - Ryan Culpepper 07:13 RacketCommitBot: [racket/master] db: fix mysql close-on-exec slowdown (TCP issue) - Ryan Culpepper 07:13 (part) RacketCommitBot 07:16 (quit) malkomalko: Remote host closed the connection 07:48 (join) malkomalko 07:51 (join) mceier 07:56 (quit) rostayob: Quit: WeeChat 0.3.5 07:57 (join) rostayob 08:01 (quit) rostayob: Client Quit 08:02 (join) rostayob 08:10 (quit) rn_: Ping timeout: 245 seconds 08:18 (join) samth 08:18 (quit) realitygrill: Quit: realitygrill 08:38 (join) masm 08:41 (join) jeapostrophe 08:44 (quit) masm: Ping timeout: 250 seconds 08:48 (quit) dous_: Remote host closed the connection 08:49 (join) masm 08:54 (quit) masm: Ping timeout: 260 seconds 08:57 (join) masm 08:58 (quit) jeapostrophe: Ping timeout: 240 seconds 09:03 (quit) masm: Ping timeout: 276 seconds 09:08 rostayob: not strictly racket but... is there any way to use paredit in a geiser prompt? 09:11 (join) Diarmid1 09:17 (join) dous_ 09:17 (join) tgilray` 09:19 (quit) Diarmid: *.net *.split 09:19 (quit) tgilray: *.net *.split 09:22 (quit) dous_: Ping timeout: 260 seconds 09:23 (join) masm 09:24 (join) dous_ 09:27 (quit) masm: Ping timeout: 252 seconds 09:35 (join) masm 09:39 (quit) masm: Ping timeout: 264 seconds 09:39 rostayob: also, why can't I match with '.' in racket? 09:40 (join) masm 09:41 rostayob: for example, if I need to match (a b c . rest), what's the best way? 09:42 bremner: (a b c d ... ) maybe 09:42 rostayob: bremner: well but how do I refer to the "..."? 09:42 rostayob: also Ii think you meant (list a b c d ...) 09:42 bremner: everything gets shoved in d irrc 09:42 (quit) malkomalko: Remote host closed the connection 09:43 bremner: yeah, probably I did mean (list a b c d ...) 09:43 rostayob: oh, ok, I'll try 09:44 rostayob: still, wouldn't the dot notation be much more concise? I guess the way racke tdoes it is less ambiguous... 09:44 bremner: not sure. There is of course cons patterns if you just want the first. 09:44 bremner: I find cons is almost always better than list for my uses 09:58 (quit) mye: Ping timeout: 246 seconds 09:59 (quit) masm: Ping timeout: 246 seconds 10:00 (join) masm 10:04 rostayob: I want to create a macro that simply transforms an S-expression instead of a syntax-object, that would be an non-hygienic macro right? 10:05 rostayob: in my case, this is the transformation I want: http://vpaste.net/0DN9b 10:06 rostayob: so if I have an expression (parser . rest) 10:06 rostayob: I want 'rest' to be transformed according to that function 10:06 rostayob: how do I do that in racket? 10:06 (quit) masm: Ping timeout: 250 seconds 10:09 (join) masm 10:10 rostayob: and I'm pretty sure that I can't do that with an hygienic macro, since the point of that macro is to keep the provided identifiers 10:11 neilv: you can do anything in syntax-case or syntax-parse 10:12 rostayob: ok, so how would you do what I posted? 10:13 neilv: i'll have to look in a minute. running debugger 10:14 rostayob: ok, thanks :) 10:14 (quit) masm: Ping timeout: 250 seconds 10:18 (join) masm 10:31 (quit) masm: Ping timeout: 272 seconds 10:33 (join) realitygrill 10:35 (join) fftb_ 10:35 (quit) fftb: Read error: Connection reset by peer 10:44 chandler: rostayob: It doesn't even look like you need more than syntax-rules here. 10:46 (quit) AlbireoX: Read error: Connection reset by peer 10:46 rostayob: chandler: so the names of the identifiers will be preserved through the transformation? 10:47 chandler: Uh, I'm not quite sure how to answer that. 10:48 chandler: I suspect you're thinking of syntax-rules et al as renaming identifiers under the hood. 10:49 (join) asdfhjkl 10:49 chandler: That's not actually how it's implemented, though. It's better to think of it as not discarding scope information. 10:49 (join) masm 10:50 chandler: In this case, there's no reason to do that, nor is there anything I see which is introducing new identifiers. 10:50 rostayob: yes, that was my question. 10:50 rostayob: ok let me try... (i'm totally new to lisp macros) 10:53 rostayob: chandler: mhm... this http://vpaste.net/9jp4I always seems to match the last case, e.g. (parser a <- foo) doesn't throw an error 10:54 chandler: The way you match literals in `syntax-rules' is a bit different. 10:55 chandler: Instead of using '<- inside the rules, just use <- . You'll also need to put <- in the list of literals to the syntax-rules form, which you currently have as just (). 10:55 chandler: Here's a concrete example: 10:56 rostayob: chandler: oh well that works, thanks 10:56 chandler: rudybot: eval (define-syntax foo (syntax-rules (<-) ((foo <-) "got a <-") ((foo bar) "didn't get a <-"))) 10:56 rudybot: chandler: Done. 10:56 chandler: rudybot: eval (foo <-) 10:56 rudybot: chandler: ; Value: "got a <-" 10:56 chandler: rudybot: eval (foo test) 10:56 rudybot: chandler: ; Value: "didn't get a <-" 10:57 chandler: rostayob: Also, the way you're using `error' there causes the error to be raised at run time, not at expansion time. 10:57 rostayob: chandler: ok, I should raise a syntax-error rigth? 10:58 chandler: This is something that's not particularly obvious with syntax-rules. I'm looking to see if there's a good way to do it in Racket. 11:00 chandler: Hm; I'm not seeing it. A lot of people do something like this: 11:00 rostayob: chandler: you mean the error? 11:01 chandler: How to raise an error at compile time in a syntax-rules macro. 11:01 rostayob: yeah 11:01 chandler: rudybot: eval (define-syntax syntax-error (syntax-rules () ((_) (syntax-error "syntax error")))) 11:01 rudybot: chandler: Done. 11:01 chandler: rudybot: eval (syntax-error "parser must end with non-binding form") 11:02 rudybot: chandler: error: #:1:0: syntax-error: bad syntax in: (syntax-error "parser must end with non-binding form") 11:02 rostayob: yep that works 11:02 rostayob: thanks a lot 11:04 (quit) vkz: Quit: vkz 11:04 (join) yoklov 11:04 (quit) masm: Ping timeout: 255 seconds 11:06 chandler: Some kind of "magic" syntax-rule-error form would be nice to have, I think. 11:06 chandler: Magic in the sense that it would provide the right expression to `raise-syntax-error'. 11:19 (join) masm 11:27 (join) GeneralMaximus 11:36 (quit) cdidd: Ping timeout: 260 seconds 11:38 rostayob: ok, wrote my first racket program! a little parser combinator in the style of parsec 11:38 rostayob: https://gist.github.com/2075565 11:39 rostayob: if anyone could point out weirdness I'd be very grateful! 11:41 neilv: whew. http://lists.racket-lang.org/users/archive/2012-March/051066.html 11:41 neilv: rostayob: did you get your question answered, or should i look through the irc logs? 11:41 rostayob: neilv: yes, I did 11:42 rostayob: I had misunderstood how syntax objects work 11:47 rostayob: the only thing that I don't like is that pattern-matching is kind of verbose 11:49 (join) dnolen 11:49 (quit) masm: Ping timeout: 252 seconds 11:50 (join) masm 11:52 neilv: rostayob: congrats on your program. you might like to try syntax-case next 11:53 rostayob: neilv: I'll read up on the difference :) 11:53 neilv: syntax-case lets you manipulate the syntax objects with arbitrary racket code 11:53 neilv: syntax-parse then adds a few things in addition to what syntax-case does 11:54 rostayob: ok 11:55 rostayob: now, markdown parser! 11:56 rostayob: btw, what ports does file-position work with? 11:56 rostayob: ah 11:56 rostayob: In position-setting mode, file-position raises the exn:fail:contract exception for port kinds other than file-stream and string ports. 11:56 rostayob: which is more or less what I need 11:58 neilv: i'm not sure why you'd need to do random access i/o. you have recursion. (if you needed really fancy stuff for speculative search-like parsing, you could use first-class continuations, but i doubt you need that) 12:03 (join) jldavis76 12:06 (quit) realitygrill: Quit: realitygrill 12:09 (join) realitygrill 12:10 (quit) masm: Ping timeout: 246 seconds 12:12 (join) masm 12:14 (join) Shvillr_ 12:14 (join) vkz 12:15 (quit) Shviller: Disconnected by services 12:15 (nick) Shvillr_ -> Shviller 12:16 (quit) vkz: Client Quit 12:17 (quit) realitygrill: Quit: realitygrill 12:17 (quit) masm: Ping timeout: 276 seconds 12:19 (join) masm 12:19 (quit) fftb_: Remote host closed the connection 12:21 rostayob: neilv: ? you mean I should just carry around a string instead of manipulating a port? 12:25 (quit) masm: Ping timeout: 244 seconds 12:25 neilv: i'm talking about writing a recursive descent parser, recursively 12:25 rostayob: well, I will write it recursively using those combinators 12:26 rostayob: actually now that I'm thinking about it it might be a bit annoying without lazyness... 12:26 neilv: so the frames (or whatever) for the recursion can hold onto characters that you need for backtracking 12:27 (join) fftb 12:29 rostayob: mhm... what I'd do in Haskell (and what parsec does) is to consume a string and implement 'try' saving the string, trying to parse and putting the initial string back if we fail 12:29 rostayob: I'm not sure if this is what you suggest 12:29 (join) masm 12:29 rostayob: I wanted to try to do it with ports because I want interoperability with the html parser, that works with ports 12:31 neilv: ok, i see. so you might want to look at input and later decide to put it back for a different parser you don't control to look at 12:32 rostayob: yes 12:32 neilv: if you only need a little lookahead, you can use peek-char instead of read-char 12:32 rostayob: yeah I know but I don't want to worry about those things, I just want a combinator that tries to parse and restore the previous situation if it fails. 12:32 neilv: or you could make a port abstraction that lets you unread or push characters onto it 12:33 neilv: you can define your own ports in racket 12:33 rostayob: yes that would work, but why bother? 12:33 rostayob: I mean what's the disadvantage of how it works currently, apart from the fact that it works only with strings and files? 12:34 (quit) masm: Ping timeout: 260 seconds 12:34 neilv: probably no practical difference in this case 12:34 neilv: the difference is whether you can stream 12:35 rostayob: "stream"? 12:35 rostayob: as in using custom ports? 12:35 neilv: i just mean that, with ports, you can read some input before all the input is available, and you don't necessarily have to keep all the input in memory at once 12:36 rostayob: well but that would work anyways, assuming that the port implementation for files reads incrementally 12:36 (part) jldavis76 12:36 rostayob: anyway it's not a big deal for me, all I need to parse is strings and files that fit in memory :P 12:38 (join) masm 12:42 (quit) Diarmid1: Quit: Leaving. 12:42 (join) Diarmid 12:44 (join) jonrafkind 12:45 (quit) masm: Ping timeout: 252 seconds 12:47 (join) masm 12:53 (quit) fftb: Remote host closed the connection 13:01 (quit) masm: Ping timeout: 252 seconds 13:04 (join) masm 13:04 (join) MayDaniel 13:10 (quit) masm: Ping timeout: 265 seconds 13:11 (quit) neilv: Quit: Leaving 13:13 (join) masm 13:15 (quit) dnolen: Ping timeout: 245 seconds 13:17 (join) realitygrill 13:20 (quit) masm: Ping timeout: 240 seconds 13:22 rostayob: mh. If I import a module with prefix-in and then I use a macro from that module, if that macro then expands using functions from that module it seems that it can't find it, possibly because the macro doesn't qualify it with the prefix 13:22 rostayob: is there a way around this? 13:23 (join) mithos28 13:24 (join) masm 13:24 (join) djcb 13:28 rostayob: no, my bad 13:29 (quit) masm: Ping timeout: 264 seconds 13:32 (join) masm 13:32 (quit) MayDaniel: Read error: Connection reset by peer 13:36 (quit) masm: Ping timeout: 244 seconds 13:42 (join) masm 13:47 (join) dnolen 13:48 (quit) yoklov: Quit: computer sleeping 13:49 (quit) masm: Ping timeout: 264 seconds 13:49 (quit) Fare: Ping timeout: 246 seconds 13:52 (quit) dous_: Remote host closed the connection 13:53 (join) Skola 13:53 (join) masm 13:59 (quit) realitygrill: Quit: realitygrill 14:00 (join) bdirks 14:01 (join) jrslepak 14:02 (join) dous_ 14:02 (quit) dous_: Changing host 14:02 (join) dous_ 14:05 (quit) masm: Ping timeout: 246 seconds 14:10 (quit) bdirks: Quit: Colloquy for iPad - http://colloquy.mobi 14:10 (join) masm 14:14 (quit) masm: Ping timeout: 250 seconds 14:16 (join) masm 14:25 (quit) dous_: Remote host closed the connection 14:40 offby1: So ... my racket program is using a surprisingly large amount of memory. How does one go about investigating? 14:50 (join) yoklov 15:07 (join) realitygrill 15:12 (quit) realitygrill: Client Quit 15:23 (join) jeapostrophe 15:37 rostayob: is it normal that something that compiles with #lang racket doesn't with #lang lazy? 15:37 rostayob: with "compiles" I mean that I can load it 15:37 (quit) jonrafkind: Ping timeout: 246 seconds 15:39 offby1: I don't use lazy, but it's not surprising. 15:39 offby1: they are, after all, different languages 15:41 (quit) GeneralMaximus: Quit: Leaving 15:42 (join) realitygrill 15:46 rostayob: uhm, ok 15:47 rostayob: I'm really missing lazyness, I'm defining a parser using some parser combinators and for recursive definitions it's a big win 16:23 Diarmid: rostayob: Why don't you use the lazyness normally available (not in #lang lazy)? 16:23 rostayob: Diarmid: you mean create thunks manually? 16:23 rostayob: or is there some lazy keyword? 16:23 chandler: rostayob: `delay' and `force' implement explict laziness. 16:24 rostayob: actually I'm thinking of converting the "choice" operator in a macro, which would solve problems. 16:24 rostayob: ah. cool. 16:25 Diarmid: rostayob: http://docs.racket-lang.org/reference/Delayed_Evaluation.html 16:26 rostayob: Diarmid: that's great. thanks. 16:26 rostayob: I still think I'll create a macro 16:26 rostayob: to explore macros more ehe 16:26 rostayob: Diarmid: btw, I'm quite satisfied with my parsec clone apart from this problem :) 16:27 rostayob: I like this language! 16:29 (join) nilyaK 16:31 Diarmid: rostayob: I like parseq and fmt. 16:32 (join) jonrafkind 16:32 rostayob: I wonder h ow they solve that problem 16:38 rostayob: also, is there a top-level letrec? 16:39 chandler: Hm. What are you trying to do? 16:39 chandler: Multiple `define' forms at the top level are roughly equivalent to `letrec'. 16:40 chandler: rudybot: eval (begin (define f (lambda (x) (if (zero? x) #t (g (sub1 x))))) (define g (lambda (x) (if (zero? x) #f (f (sub1 x)))))) 16:40 rudybot: chandler: Done. 16:40 chandler: rudybot: eval (f 4) 16:40 rudybot: chandler: ; Value: #t 16:40 rostayob: no, what I meant is something of the form (define foo ...some expression using foo ...) 16:40 chandler: That's fine too. 16:41 rostayob: oh right 16:41 rostayob facepalms 16:41 chandler: As long as you don't need to take the value of `foo' in the process of evaluating that expression. 16:43 rostayob: chandler: I asked this because this: http://vpaste.net/TBNLE doesn't work, while defining it as a 0-ary function - (pexpr) - works 16:43 rostayob: but the problem is probably elsewhere 16:45 chandler: Hm. I wouldn't expect to see multiple forms in the expression part of a `define' form like that. I know there was some talk of allowing that recently on the Racket list, but I don't see any reference to that being allowed in the documentation. 16:45 chandler: rudybot: eval (define x (define y 1) y) 16:45 rudybot: chandler: error: #:1:0: define: bad syntax (multiple expressions after identifier) in: (define x (define y 1) y) 16:46 chandler: rudybot: eval (define x (begin (define y 1) y)) 16:46 rudybot: chandler: error: #:1:17: define: not allowed in an expression context in: (define y 1) 16:46 rostayob: yeah, that is the problem... but then why does it work if it's a function? 16:46 chandler: rudybot: eval (define x (local (define y 1) y)) 16:46 rudybot: chandler: error: #:1:18: define: bad syntax in: define 16:46 rostayob: rudybot: (define (x) (write 'foo) (write 'bar)) 16:46 rudybot: rostayob: your sandbox is ready 16:46 rudybot: rostayob: Done. 16:46 rostayob: rudybot: eval (define (x) (write 'foo) (write 'bar)) 16:46 rudybot: rostayob: Done. 16:47 chandler: rostayob: Because the body of a procedure is like the body of a `let' or other such binding form, and allows internal definitions. 16:47 chandler: rudybot: eval (define x (let () (define y 1) y)) 16:47 rudybot: chandler: Done. 16:47 chandler: rudybot: eval x 16:47 rudybot: chandler: ; Value: 1 16:47 rostayob: uh? 16:47 rostayob: rudybot: eval (x) 16:47 rostayob: chandler: well anyways. if it's a function it works, which confused me 16:47 rudybot: rostayob: ; stdout: "foobar" 16:47 chandler: Right, hence the recent discussion on the list about allowing this, but I don't remember what became of it. 16:48 rostayob: why would it be different for procedures? 16:49 chandler: Because (define (f a ...) e ...) is just syntactic sugar for (define f (lambda (a ...) e ...)) . 16:49 chandler: And in the body of a `lambda', you can use local definitions. 16:50 chandler: Personally, I've always preferred to just write (define f (lambda ...)), which I've been informed is an IU tic. (Guilty as charged.) 16:50 rostayob: IU? 16:50 chandler: Indiana University 16:50 rostayob: ah :) 16:52 chandler: I'm a little confused as to why (local (define y 1) y) doesn't work, actually. 16:53 chandler: Er, in a top-level context that is. 17:06 (quit) realitygrill: Quit: realitygrill 17:12 (join) stis 17:13 stis: Hey! Why does racket have one local-syntax lookup function that lookup syntax-parameters and one that don't? 17:13 jeapostrophe: chandler: you are missing a paren 17:14 jeapostrophe: rudybot: (local [(define y 1)] y) 17:14 rudybot: jeapostrophe: your sandbox is ready 17:14 rudybot: jeapostrophe: ; Value: 1 17:14 chandler: Oh! 17:14 chandler: Sorry. I must not be able to read today. 17:15 jeapostrophe: stis: syntax-local-value looks up the phase-1 binding associated with a piece of syntax, syntax-parameter-value is different because there is no phase-1 binding associated with the stx parameter , or rather there is, but it's not the value the parameter is currently bound to 17:16 stis: thanks! 17:18 jeapostrophe: stis: syntax-parameter-value is much less useful than syntax-local-value 17:18 jeapostrophe: stis: and, syntax-local-value is pretty advanced macrology, so you probably don't need it for what you're doing... i'm guessing :) 17:19 jeapostrophe: stis: and finally, if you DID need it, it would be better to use 'static' from 'syntax/parse' 17:19 jeapostrophe: than calling it directly 17:19 chandler: Oh, it's `block' I was trying to think of, not `local'. 17:20 chandler: Though apparently `block' can't be used in an expression context... 17:21 jeapostrophe: chandler: ya, that's different/nicer, but actually unnecessary because 'begin' already does that now 17:22 chandler: Is there a form equivalent to (let () body ...) to let internal definitions be used in an expression context? It's obviously semantically unnecessary, but it's nice to not have an empty binding form where it's not needed. 17:26 stis: jeapostrophe: I've ported syntax parse over to guile and needed something like 17:27 jeapostrophe: chandler: begin does that 17:27 chandler: rudybot: eval (define x (begin (define y 1) y)) 17:27 rudybot: chandler: your sandbox is ready 17:27 rudybot: chandler: error: #:1:17: define: not allowed in an expression context in: (define y 1) 17:27 stis: syntax-local-value, We have the option there to let syntax local value return the binding of a syntax-parametrized syntax parameter as well, can that be a bad strategy? 17:28 chandler: What am I missing? 17:29 jeapostrophe: rudybot: (version) 17:29 rudybot: jeapostrophe: ; Value: "5.2.1" 17:31 jeapostrophe: chandler: hmm, i guess the splicing behavior of begin causes a problem. block works there though 17:31 jeapostrophe: stis: that's not what syntax-local-value does... it's not really about syntax-parameters 17:31 chandler: rudybot: eval (define x (block (define y 1) y)) 17:31 rudybot: chandler: error: #:1:17: define: not allowed in an expression context in: (define y 1) 17:33 jeapostrophe: rudybot: (require racket/block) (define x (block (define y 1) y)) 17:33 rudybot: jeapostrophe: hmm. i guess it depends on the kind of people that you're trying to ensure understand your code. i might be wrong, but i'd think any seasoned lisp programmer would automatically translate car, cdr to what those functions represent (i.e., first and rest). i agree it's a stumbling block for new programmers (since they have to understand new notation) and that the fewer such requirements are made for people to mem 17:33 (join) realitygrill 17:33 chandler: Heh. 17:33 chandler: offby1: That's really confusing. 17:33 stis: ok! I need to read melt things for know, thanks again! 17:33 jeapostrophe: rudybot: (define x (block (define y 1) y)) 17:33 rudybot: jeapostrophe: error: #:1:17: define: not allowed in an expression context in: (define y 1) 17:34 chandler: jeapostrophe: Nevermind rudyboy; I see now. 17:34 jeapostrophe: doesn't work because it is parsed as (#%app block (define y 1) y) 17:34 chandler: "rudybot" 17:34 chandler: Yes, I figured that out. 17:34 jeapostrophe: because block isn't in racket or racket/base, but racket/block 17:35 offby1: chandler: it only evals if it can "read" what you say into exactly one expression. 17:36 chandler: offby1: Not to be an ass about this, but what exactly is the purpose of the old-message-quoting thing? I hardly ever see it triggered deliberately, and I don't think it's ever been amusing. 17:38 offby1: chandler: I think it's very funny. 17:38 offby1: And that is its purpose. 17:38 offby1: in fact I'm working hard at "improving" it now. 17:38 jamessan: offby1: does it build the response with markov chains? 17:38 chandler: OK. Personally I think it'd be most useful if anything that didn't look like a recognized command was treated as a sequence of expressions. 17:39 offby1: chandler: perhaps I could have it do the funny-response only if it couldn't parse a sequence of expressions. 17:40 offby1: jamessan: no. It's pretty simple: it breaks what you say up into words, then looks through its "corpus" of previous utterances, finds the word that you said that appears the fewest times (and hence is most "interesting"), then chooses a random utterance that contains that word. 17:40 offby1: that's all 17:40 offby1: right now I'm trying to make the corpus live in a sqlite db instead of just hanging out in RAM 17:47 (quit) acarrico: Ping timeout: 260 seconds 17:49 (part) stis 17:50 (join) acarrico 17:55 (join) tiagosr 17:58 (quit) jonrafkind: Ping timeout: 248 seconds 18:07 (quit) nilyaK: Quit: Leaving. 18:17 (quit) Skola: Quit: Lost terminal 18:18 (quit) djcb: Remote host closed the connection 18:19 (join) djcb 18:51 (join) rostayob1 18:52 (quit) yoklov: Quit: computer sleeping 18:54 (quit) rostayob: Ping timeout: 276 seconds 18:56 (join) yoklov 19:09 (join) vkz 19:20 rostayob1: uhm. is there anything wrong with this macro: http://vpaste.net/f0UHH ? 19:20 offby1: yeah, it's got weird colors :) 19:21 rostayob1: :) apart from that? 19:21 offby1: seriously, I dunno; my syntax-fu is but weak 19:23 rostayob1: because I'm unable to use it. however I call it it says "bind: illegal use of syntax " 19:23 (quit) jeapostrophe: Read error: Operation timed out 19:24 chandler: I'm not sure how you're intending this macro to be used, but one thing to note is that `syntax-case' patterns look just like `syntax-rules' patterns. 19:24 chandler: Also, that `define-syntax' form doesn't really look right. Low-level macros receive one argument, which is a "syntax object". 19:24 chandler: Here's an example of a `syntax-rules' macro and its `syntax-case' equivalent: 19:25 chandler: rudybot: eval (define-syntax foo (syntax-rules () ((_ a) 1) ((_ a b) 2))) 19:25 rudybot: chandler: Done. 19:25 rostayob1: chandler: I've already redefined the old macro with syntax-case, and it works 19:25 chandler: rudybot: eval (define-syntax foo^ (lambda (stx) (syntax-case stx () ((_ a) #'1) ((_ a b) #'2)))) 19:25 rudybot: chandler: Done. 19:26 rostayob1: chandler: ok, so it always gets one argument that then you pattern match 19:26 chandler: Yup. 19:26 rostayob1: the thing is that 19:26 rostayob1: I want to execute something 19:26 rostayob1: and then spit out some syntax depending on the result of the computation 19:27 rostayob1: can I do that inside define-syntax? 19:27 chandler: Right, well, that's what this is here for. :-) 19:27 chandler: But there are two big things you'll need to be aware of. One is the difference between syntax and an ordinary datum. The other is phases. 19:28 rostayob1: chandler: so syntax = syntax object, datum = scheme list, right? 19:29 chandler: Yes - though a datum can be other things, too. 19:29 rostayob1: like? 19:29 chandler: Like a symbol, or a literal. 19:29 rostayob1: oh, right. 19:30 rostayob1: just a sec... 19:30 (quit) rostayob1: Quit: WeeChat 0.3.5 19:30 (join) rostayob 19:30 (join) jonrafkind 19:31 rostayob: chandler: ok. now, back to my question... how can I execute some computation inside define-syntax while mantaining all the info in the syntax object? it looks like I shouldn't be able to 19:31 chandler: You definitely can do that. What are you trying to compute? 19:32 rostayob: well this is the original definition of >>=: http://vpaste.net/DOHwz 19:32 rostayob: I'd like to define a macro that does the same. this is to avoid the execution of "f" if >>= is a normal function 19:33 (join) dzhus 19:33 rostayob: so the macro would generate a function (lambda (port) ...), where (p port) gets executed, and if it fails it just stops. if it succeeds it executes 'f result'. 19:34 rostayob: so if I have something like (>>= a (b c d)) if a fails (b c d) won't be executed 19:34 rostayob: (if I understand correctly how macros work). 19:34 chandler: OK. I don't think you actually need to compute anything at compile-time here; I think you just need to create a small macro that expands into the right definition. 19:35 chandler: rudybot: eval (begin (define (my-big-hairy-expensive-function) (printf "I'm running!\n") #t) (define (my-test-function) #f)) 19:35 rudybot: chandler: Done. 19:36 chandler: rudybot: eval (define (my-proc test-fn val) (if (test-fn) val 42)) 19:36 rudybot: chandler: Done. 19:36 chandler: rudybot: eval (my-proc my-test-function (my-big-hairy-expensive-function)) 19:36 rudybot: chandler: ; Value: 42 19:36 rudybot: chandler: ; stdout: "I'm running!\n" 19:36 chandler: So, that's the problem, right? 19:37 rostayob: chandler: yes. 19:37 chandler: rudybot: eval (define (my-proc^ test-fn compute-val) (if (test-fn) (compute-val) 42)) 19:37 rudybot: chandler: Done. 19:38 chandler: rudybot: eval (define-syntax my-macro (syntax-rules () ((_ test-fn val) (my-proc^ test-fn (lambda () val))))) 19:38 rudybot: chandler: Done. 19:38 rostayob: oh right, I can create a thunk manually, I suppose. 19:38 chandler: rudybot: eval (my-macro my-test-function (my-big-hairy-expensive-function)) 19:38 rudybot: chandler: ; Value: 42 19:38 rostayob: and then unthunk it 19:38 rostayob: right. thanks. 19:39 chandler: You can also use `lazy' and `force' there if it's useful to be able to pass around the promise internally. 19:40 rostayob: yes, Diarmid suggested that, but I wanted to explore macros more :) 19:41 chandler: Sure. You might still want to use macros to hide the laziness even if you do end up using promises. 19:43 offby1: my-big-fat-greek-function 19:48 rostayob: chandler: whooo, it works. thanks a lot. 20:03 (join) dous_ 20:11 offby1: it's cold here in Seattle, but I'm keeping warm because I'm running "make install" on my laptop! :-P 20:11 offby1: even better than a cat. 20:18 (join) jeapostrophe 20:23 (quit) mceier: Quit: leaving 20:30 rostayob: chandler: the problem is that that doesn't really solve my problem, because all the other combinators that I use will still evaluate their arguments 20:30 rostayob: in general I can't rely on them... I think I'll just use `lazy' 20:32 rostayob: is there something like "delay" and "lazy" but without the need to force them explicitely? 20:32 asumu: offby1: Funny enough, it's very warm here in Boston. 20:33 asumu: Weird weather this year. 20:33 offby1 has a Kramer moment 20:33 offby1: if only there were a way to ship our weather East, and yours West ... 20:34 (quit) jeapostrophe: Ping timeout: 245 seconds 20:39 (quit) gf3: Excess Flood 20:40 (quit) yoklov: Quit: computer sleeping 20:42 (join) gf3 21:07 (quit) tiagosr: Ping timeout: 245 seconds 21:13 (join) cdidd 21:17 (quit) dzhus: Remote host closed the connection 21:31 (quit) rostayob: Ping timeout: 276 seconds 21:35 (quit) dous_: Remote host closed the connection 21:45 (quit) masm: Quit: Leaving. 21:48 (quit) asdfhjkl: Ping timeout: 252 seconds 21:52 (join) AlbireoX 22:18 (quit) samth: Ping timeout: 276 seconds 22:21 (quit) mithos28: Quit: mithos28 22:47 (join) nilyaK 23:02 (quit) offby1: Read error: Connection reset by peer 23:02 (quit) rudybot: Read error: Connection reset by peer 23:03 (join) offby1 23:03 (quit) offby1: Changing host 23:03 (join) offby1 23:58 (join) jeapostrophe