00:03 eli: Fare: So I'm not following what you said... 00:04 eli: If you're just talking about that processor knowing that `foo' is defined as (listof integer?) (or whatever compiles to that), then you can see that in my code -- `foo' is bound to a macro-level thing, and its value has the original expression. 00:05 eli: So that supposed type language compiler would use the same `syntax-local-value' thing to know about type definitions. 00:23 Fare: where is that syntax-local-value defined? 00:23 eli: Fare: It's part of the core language. 00:24 eli: Roughly speaking, its a way to get the value of a syntax binding, which is normally a transformer function which is used only as an expander. 00:24 eli: rudybot: (syntax-local-value #'when) 00:24 rudybot: eli: your sandbox is ready 00:24 rudybot: eli: error: syntax-local-value: not currently transforming 00:24 eli: rudybot: (begin-for-syntax (syntax-local-value #'when)) 00:24 rudybot: eli: Done. 00:24 eli: Meh. 00:25 eli: rudybot: (define-syntax (show-stx stx) (syntax-case stx () [(_ id) (eprintf ">>> ~s -> ~s\n" (syntax-e #'id) (syntax-local-value #'id)) #'(void)])) 00:25 rudybot: eli: Done. 00:25 eli: rudybot: (show-stx when) 00:25 rudybot: eli: ; stderr: ">>> when -> #\n" 00:25 eli: Fare: There. 00:26 eli: That # thing is the expander for `when'. 00:26 eli: Now, the thing is that you can use `define-syntax' with random values, which is used only as value holders, not as macros. 00:26 eli: rudybot: (define-syntax fooo "what?") 00:26 rudybot: eli: Done. 00:26 eli: rudybot: fooo 00:26 rudybot: eli: error: #:1:0: fooo: illegal use of syntax in: fooo 00:27 eli: That's because it's not an expander function. 00:27 eli: rudybot: (show-stx fooo) 00:27 rudybot: eli: ; stderr: ">>> fooo -> \"what?\"\n" 00:27 eli: And that took its value. 00:32 veer: ok silly question follows: so invariant(in context of PL) means some condition that holds before function call and after function call right? And I can express this using racket contracts right? I can also use normal racket expression to do so for eg. https://gist.github.com/3022279 00:33 offby1: I don't think you can use contracts to express invariants. 00:34 veer: I see , so what contracts are used for ? 00:35 offby1: I use 'em to check preconditions and postconditions 00:40 (quit) jrslepak: Read error: Operation timed out 00:40 veer: So in my case precondition is same as postcondition , so it this a case of something being invariant ? I'll look into contracts in manual later 00:47 (join) jrslepak 00:49 (quit) jeapostrophe: Ping timeout: 250 seconds 00:54 (quit) siduction: Quit: Leaving 01:22 (quit) mmalorni: Ping timeout: 246 seconds 01:31 (quit) jacius: Quit: Leaving 01:31 (quit) rbarraud: Read error: Connection reset by peer 02:20 (quit) Kaylin: Quit: Leaving. 03:06 (join) mceier 03:09 (join) antithesis 03:18 (join) jesyspa 03:19 (quit) jonrafkind: Ping timeout: 240 seconds 03:32 (join) dalaing 04:12 (join) dalaing1 04:14 (quit) dalaing: Read error: Connection reset by peer 04:16 (join) snearch 04:16 (join) zaamkablam 04:32 (join) chemuduguntar 04:49 (quit) zaamkablam: Ping timeout: 240 seconds 04:49 (quit) dalaing1: Quit: Leaving. 04:55 (quit) chemuduguntar: Read error: No route to host 04:55 (join) dalaing 04:59 (quit) ssbr__: Ping timeout: 246 seconds 05:00 veer: allright! understood how pre and post conditions helps , example https://gist.github.com/3022699 , without proof. So basically I only need to prove pre-cond => post-cond to say function is correct for post-cond 05:01 veer: I like this idea of specifying pre and post conds and including it in program 05:08 (quit) jesyspa: Quit: Lost terminal 05:10 (quit) antithesis: Quit: antithesis 05:14 (join) neilv 05:14 (join) ssbr__ 05:15 neilv: ">sgl/gl.html#(def._((lib._sgl/gl..rkt)._.G.L_.C.O.M.P.R.E.S.S.E.D_.I.N.T.E.N.S.I.T.Y))" 05:21 (join) jesyspa 05:30 (quit) dalaing: Read error: Connection reset by peer 05:35 (join) masm 05:41 (quit) jyc: Read error: Connection reset by peer 05:45 (quit) masm: Quit: Leaving. 05:49 (quit) Fare: Ping timeout: 240 seconds 06:01 (join) rbarraud 06:04 (join) Fare 06:07 (join) bitonic 06:14 (quit) rbarraud: Read error: Connection reset by peer 06:19 (join) rbarraud 06:29 (join) bitonic` 06:30 (quit) bitonic: Ping timeout: 246 seconds 06:34 (join) bitonic`` 06:35 (quit) bitonic`: Ping timeout: 246 seconds 06:51 (quit) rbarraud: Ping timeout: 255 seconds 06:54 (quit) ssbr__: Ping timeout: 264 seconds 06:56 (quit) jesyspa: Quit: leaving 06:59 (nick) bitonic`` -> bitonic 07:11 (quit) Fare: Ping timeout: 246 seconds 07:32 (join) antithesis 07:35 (quit) veer: Ping timeout: 246 seconds 07:45 (join) soegaard 07:50 (join) veer 07:58 (quit) Shviller: Ping timeout: 246 seconds 07:59 (join) Shviller 08:03 (quit) snearch: Quit: Verlassend 08:16 (quit) antithesis: Quit: antithesis 08:21 (join) snearch 08:41 (join) Kaylin 08:53 (quit) neilv: Quit: Leaving 08:55 (join) anttih 09:14 (join) jeapostrophe 09:17 (join) bitonic` 09:22 anttih: what are the performace characteristics of Racket's immutable hash tables? Does modification copy the whole table or is the old structure reused? 09:25 (join) anRch 09:27 anttih: I assume it is reused as much as possible. 09:33 (quit) snearch: Quit: Verlassend 09:46 (join) ssbr__ 10:00 soegaard: Well, since it is immutable it can't really be modified. However one can make new hash tables and the new hash tables shares some of its internal structure with the old (but this ought not be observable from the outside) 10:01 (join) jao 10:02 (quit) jao: Changing host 10:02 (join) jao 10:03 (quit) anRch: Quit: anRch 10:27 (quit) Kaylin: Quit: Leaving. 10:32 (join) _p4bl0` 10:35 (join) jeremyheiler 10:39 (quit) _p4bl0`: Remote host closed the connection 10:39 (join) _p4bl0`` 10:47 (quit) jeapostrophe: Ping timeout: 246 seconds 10:47 (part) _p4bl0``: "ERC Version 5.3 (IRC client for Emacs)" 10:54 (quit) wahjava: Quit: You've got to hide your love away 10:58 (join) wah_java 11:04 (quit) BeLucid_: Ping timeout: 248 seconds 11:05 (nick) wah_java -> wahjava 11:30 (join) jeapostrophe 11:30 (quit) jeapostrophe: Changing host 11:30 (join) jeapostrophe 11:43 (quit) jeapostrophe: Ping timeout: 265 seconds 11:52 (quit) veer: Quit: Leaving 11:56 (join) wah_java 11:59 (join) jonrafkind 11:59 (quit) jonrafkind: Changing host 11:59 (join) jonrafkind 12:06 (join) Fare 12:09 (quit) jonrafkind: Ping timeout: 244 seconds 12:10 (quit) wah_java: Quit: Machines are always better than humans 12:17 (quit) jeremyheiler: Quit: Computer has gone to sleep. 12:50 (quit) lcc: Quit: ERC Version 5.3 (IRC client for Emacs) 12:51 Fare: eli: do you have a protocol so that modules can add their own sauce to the client's whole-module expansion? 13:02 (join) wahjava 13:23 (quit) jao: Ping timeout: 246 seconds 13:31 eli: Fare: What do you mean? 13:34 Fare: do you ever find a need for a module to extend the language in such a way as to require global effects? Can you do it in modular ways, or only as "this module controls the entire language, and others can only have local effects"? 13:42 eli: Fare: There are several answer to that. 13:42 eli: One thing is that each module's toplevel gets to run when the module is instantiated. 13:42 eli: (Which is only once, unless you're doing sandboxing or macros etc.) 13:43 eli: So you could combine toplevel side-effect things by just requiring modules. 13:44 eli: More than that, it used to be the case that the instantiation order was not defined, but recently (IIRC) it was changed so that (require foo bar) will instantiate them in order. 13:44 eli: But since they're used for linking, the required modules get instantiated before the requiring module does. 13:44 eli: rudybot: (module A racket (printf "A\n")) 13:44 rudybot: eli: Done. 13:44 eli: rudybot: (module B racket (printf "B\n")) 13:44 rudybot: eli: Done. 13:45 eli: rudybot: (module C (printf "C\n") (require 'A 'B)) 13:45 rudybot: eli: error: #:1:10: module: initial import is not a well-formed module path at: (printf "C\n") in: (module C (printf "C\n") (require (quote A) (quote B))) 13:45 eli: rudybot: (module C racket (printf "C\n") (require 'A 'B)) 13:45 rudybot: eli: Done. 13:45 eli: rudybot: (require 'C) 13:45 rudybot: eli: ; stdout: "B\nA\nC\n" 13:45 eli: Fare: So in the nightly build version, that would print A and then B for that change, 13:46 eli: and C is always printed last since it needs to finish requiring the other two before it is invoked. 13:46 eli checks 13:46 eli: Yeah. 13:47 eli: So that's one side of the story. 13:47 eli: Another side of the story is when you want a module to behave in two ways, one when it's being used as a library, and another when it's being run directly. 13:47 eli: This is also related to a recent development which we finally have now -- 13:47 eli: the new feature is submodules 13:48 eli: So a module can now have submodules, and if it is being run directly (ie, from the command line, or from the racket executable), then it will see if it has a submodule that is called `main' 13:48 eli: and if so, then it will invoke that module. 13:48 (nick) bitonic` -> bitonic 13:49 eli: So code that is put in a `main' submodule usually gets to run only when you run the module directly. 13:49 eli: (Or if you invoke it explicitly in code, of course.) 13:49 eli: Yet another aspect of this, which might be relevant to you, is dealing with languages that need to add some toplevel-ish behavior to modules. 13:50 eli: The classic example for this is a module that provides a `test' macro to write tests, 13:50 eli: and you'd usually want to do some (report-test-results) at the end of the module whos using your test facility. 13:50 eli: For that, there is one of the popular special macros -- `#%module-begin'. 13:50 (join) lcc 13:51 eli: That macro gets implicitly wrapped around the module's body, 13:51 eli: so it can be used to add top-level things to it, before, after, or even process each toplevel expression. 13:51 eli: rudybot: reset 13:51 rudybot: eli: error: reference to an identifier before its definition: reset in module: 'program 13:51 eli: rudybot: init 13:51 rudybot: eli: your sandbox is ready 13:53 eli: rudybot: (module A racket (provide (except-out (all-from-out racket) #%module-begin) (rename-out [module-begin #%module-begin])) (define-syntax-rule (module-begin E ...) (#%module-begin (printf "Starting\n") (begin (printf "Running ~s\n" 'E) E) ... (printf "Done\n")))) 13:53 rudybot: eli: Done. 13:53 eli: rudybot: (module B 'A (define x 1) (printf "x = ~s\n" x) (printf "this is not the last printout\n")) 13:53 rudybot: eli: Done. 13:54 eli: rudybot: (require 'B) 13:54 rudybot: eli: ; stdout: "Starting\nRunning (define x 1)\nRunning (printf \"x = ~s\\n\" x)\nx = 1\nRunning (printf \"this is not the last printout\\n\")\nthis is not the last printout\nDone\n" 13:54 eli: Fare: Like that. 13:54 eli: (Which would make more sense if you type it in and run it as usual...) 13:54 (join) Kaylin 14:02 (join) jacius 14:03 (join) dnolen 14:12 (part) weirdo 14:15 (quit) lcc: Quit: ERC Version 5.3 (IRC client for Emacs) 14:30 eli: Fare: Did that make sense? 14:31 Fare: eli: is #%module-begin shadowed for A? for users of A? 14:32 eli: If you use A like that, (module foo 'A ...blah...) 14:32 eli: then this module uses the `#%module-begin' binding from A. 14:32 Fare: How are such things chained between modules? 14:32 Fare: is there a module-around to do bindings? 14:33 eli: The chaining is simple -- note that A's `#%module-begin' eventually expands to its own `#%module-begin'... 14:33 eli: So it just adds a layer on top of what its own thing is doing. 14:33 eli: BTW, there's one important bit there, 14:34 eli: you can usually write something like this instead: 14:34 eli: (module foo racket (require 'A) ...blah...) 14:34 eli: and that gets you all of A's bindings instead of the ones from racket. 14:34 eli: But it won't work in this case, since `#%module-begin' is used around the body, so by the time it gets to the require it already had used the one from racket. 14:35 Fare: what if I require 'A and require 'B, and each want their new module thingie? 14:35 eli: That's one reason for the special "initial language module" thing in modules. 14:35 eli: Technically, there is no problem... 14:35 eli: Since there is only one initial language position. 14:35 eli: So, if you try (module foo racket (require 'A 'B)) 14:36 eli: and both provide a binding by the same name, you get an error. 14:37 eli: If you put it in the initial language thing, then later requires and definitions are allowed to shadow it, but in the case of `#%module-begin' that doesn't make any difference since it has already been used by the time it gets to these requires and definitions. 14:37 eli: So if you really want to combine `#%module-begin' from two modules, the best is to write a third one that uses both. 14:37 eli: Ie, something like 14:37 eli: (require (prefix-in A: 'A) (prefix-in B: 'B)) 14:37 eli: and then 14:38 eli: (define-syntax-rule (module-begin E ...) (A:#%module-begin (B:#%module-begin E ...))) 14:38 eli: (provide (rename-out [module-begin #%module-begin])) 14:38 eli: Like that. 14:40 Fare: ok, so the initial language is special and is the only one to do global stuff 14:40 Fare: what about special bindings? 14:40 Fare: how do I introduce a parameterize around the whole module? 14:40 eli: Roughly, yes. Global in the sense of can affect how the module expands. 14:40 eli: WHat do you mean? 14:41 eli: `parameterize' -- ? 14:41 Fare: yes 14:41 eli: It doesn't make sense to `parameterize' around a module's body, because it's a dynamic-extent thing... 14:41 Fare: and? 14:41 eli: So I'm not following you... 14:42 Fare: in lisp, I often bind special variables around the compilation of a source file. 14:42 eli: IOW, the parameterize would have an effect only on toplevel expressions, but it would be ignored for functions, since they're used after the module was involed. 14:43 eli: Wait, you mean special variable that control compilation? 14:43 Fare: yes 14:43 eli: Oh, that would be like using parameters at the syntax level. 14:43 eli: And there you can knock youself out... 14:43 Fare: but around the whole module 14:43 eli: Specifically, you *don't* need special variables in the parameters sense. 14:44 Fare: ? 14:44 eli: You can just have some global bindinging and `set!' it. 14:44 eli: The resulting mutation is localized to each use, since when your module is used to compile a new one, it will be re-instantiated, with a new state. 14:47 (quit) mceier: Remote host closed the connection 14:48 (join) mceier 14:59 (join) jeapostrophe 14:59 (quit) jeapostrophe: Changing host 14:59 (join) jeapostrophe 15:05 (quit) dnolen: Ping timeout: 252 seconds 15:14 (join) RacketCommitBot 15:14 RacketCommitBot: [racket] plt pushed 1 new commit to master: http://git.io/dJrRPw 15:14 RacketCommitBot: [racket/master] racket/class: doc fixes and improvements - Asumu Takikawa 15:14 (part) RacketCommitBot 15:20 (quit) Kaylin: Quit: Leaving. 15:24 (quit) maahes: Ping timeout: 240 seconds 15:27 (quit) soegaard: Quit: soegaard 15:41 (join) jeapostr1phe 15:41 (quit) jeapostrophe: Read error: Connection reset by peer 15:44 (join) maahes 15:58 (join) jsnikeris 16:11 (join) antithesis 16:31 (quit) antithesis: Quit: antithesis 16:32 (join) soegaard 16:44 (join) jonrafkind 16:52 (join) MayDaniel 17:07 (join) jao 17:07 (quit) jao: Changing host 17:07 (join) jao 17:40 (quit) wahjava: Quit: Machines are always better than humans 17:43 (quit) MayDaniel: Read error: Connection reset by peer 17:47 (quit) jeapostr1phe: Ping timeout: 246 seconds 18:00 (join) BeLucid 18:08 (quit) jacius: Ping timeout: 276 seconds 18:20 (join) jacius 18:36 (join) anRch 18:37 (quit) Myk267: Remote host closed the connection 18:53 (join) jeapostrophe 19:01 (quit) soegaard: Quit: soegaard 19:03 (quit) jeapostrophe: Ping timeout: 252 seconds 19:15 (quit) Fare: Ping timeout: 244 seconds 19:26 (quit) anRch: Quit: anRch 20:07 (join) jyc 20:15 (join) rbarraud 20:15 (quit) stchang: Read error: Operation timed out 20:18 (join) stchang 20:34 (join) asdfhjkl 20:39 (join) adu 20:43 (quit) jonrafkind: Ping timeout: 240 seconds 20:44 (quit) stchang: Read error: Operation timed out 20:46 (join) stchang 20:56 (quit) jao: Remote host closed the connection 20:59 (join) jao 20:59 (quit) jao: Changing host 20:59 (join) jao 21:10 (join) jeapostrophe 21:10 (quit) jeapostrophe: Changing host 21:10 (join) jeapostrophe 21:10 (join) Myk267 21:10 (quit) adu: Quit: adu 21:30 (quit) asdfhjkl: Quit: Leaving 21:31 (join) asdfhjkl 21:56 (quit) jeapostrophe: Ping timeout: 244 seconds 22:16 (join) Kaylin 22:19 (quit) vu3rdd: Read error: Connection reset by peer 22:20 (join) vu3rdd 22:20 (quit) vu3rdd: Changing host 22:20 (join) vu3rdd 22:58 (quit) jao: Remote host closed the connection 23:02 (join) chimeracoder 23:03 chimeracoder: For typed/racket, since round and truncate don't return Integer, what's the best way to create an integer after division? 23:03 chimeracoder: (I'm getting type errors even on an Exact Integer) 23:04 (quit) asdfhjkl: Quit: Leaving 23:06 offby1: (inexect->exact) maybe 23:06 offby1: don't really know; I don't use typed racket 23:14 chimeracoder: offby1: well, no, unfortunately the code that's causing the error is (inexact->exact (round (* foo 1.05946))) bar) 23:24 (quit) ivan\: Quit: ERC Version 5.3 (IRC client for Emacs) 23:24 (join) adu 23:28 chimeracoder: Ah, got it - for the record, you have to convert to an exact form *before* rounding 23:28 chimeracoder: http://www.digipedia.pl/usenet/thread/14667/1904/ 23:28 chimeracoder: ie, (round (inexact->exact (truncate (* 43 1.05946)))) 23:30 asumu: chimeracoder: in the next version of Racket, there's an exact-round function built-in which will give you an Integer too. 23:30 chimeracoder: asumu: ooh, thanks for letting me know 23:30 (join) jeapostrophe 23:30 (quit) jeapostrophe: Changing host 23:30 (join) jeapostrophe 23:52 (join) Fare 23:56 (join) ivan\