Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Matthew Flatt
At Mon, 4 Aug 2014 00:52:56 -0300, Henry Lenzi wrote: > What I'm sensing is that you seem to be concerned about bugs with > Racket Scheme's EVAL. Is that it? > I do not understand what the problem with EVAL is. Would you please > state clearly what the problems are? While he didn't say so explicit

Re: [racket] Performance. Higher-order function

2014-08-03 Thread Roman Klochkov
Thank you! Now it's rather clear for me. Mon, 4 Aug 2014 06:47:34 +0100 от Matthew Flatt : >Well... a function call is expensive relative to some things, such as >adding fixnums to produce a fixnum. > > >My read of your initial results is that calling an unknown function is >similar to the cost

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Neil Van Dyke
Henry Lenzi wrote at 08/03/2014 11:52 PM: What I'm sensing is that you seem to be concerned about bugs with Racket Scheme's EVAL. Is that it? I do not understand what the problem with EVAL is. Would you please state clearly what the problems are? Eval is one of the issues. Sorry I have to be v

Re: [racket] Destructors in Racket

2014-08-03 Thread Matthew Flatt
At Sat, 02 Aug 2014 21:12:50 +0400, Roman Klochkov wrote: > Here we have a thread per every module, that use such approach. It is > better,than a thread per object, but ... > How many such threads can Racket run without performance degrading? Many thousands. Each thread costs about 15 kilobytes

Re: [racket] Performance. Higher-order function

2014-08-03 Thread Matthew Flatt
Well... a function call is expensive relative to some things, such as adding fixnums to produce a fixnum. My read of your initial results is that calling an unknown function is similar to the cost of one iteration in a loop that sets a character in a string. More precisely, decompiling the progr

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Henry Lenzi
Hello Alex -- This is nice, the problem is separating the output into the proper formatting. I feel this has to be done a step before the expansion into the string form. One thing I'm considering is that that the DSL is made of MED QUANT FORM POS or MED QUANT FOR POS INST, so 4 or 5 items. If we h

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Alexander D. Knauth
Would this work for what you want? If med.rkt contains this: #lang racket (provide (all-defined-out) #%datum #%top (rename-out [new-module-begin #%module-begin])) (define-syntax-rule (new-module-begin med-thing ...) (#%module-begin (display (~a med-thing ... #:separator " "

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Henry Lenzi
I would just like to add that this is only something very embrionary. There are a myriad ways to validate the user syntax when he/she provides input. We're just not there yet! ;-) Cheers, -- Henry On Mon, Aug 4, 2014 at 12:52 AM, Henry Lenzi wrote: > Hello Neil - > > First of all, I am not atte

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Henry Lenzi
Hello Neil - First of all, I am not attempting tricks. I am doing the best I can, the way I know how to (I will take the "clever" part as a compliment, however). I have a few rational requirements, which I have explained. Foremost among them is code simplicity. I saw no need so far for parsers or

Re: [racket] Performance. Higher-order function

2014-08-03 Thread Roman Klochkov
> unknown function call is expensive So, higher order function always slow. Thus, to improve performance, one should use for/fold, for/list, ... and never use map, foldl, build-string, ... with lambda. Is it correct? Sun, 3 Aug 2014 13:15:57 -0400 от Matthias Felleisen : > >Because build-strin

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Neil Van Dyke
I can see how someone might want to do tricks like this, to use the REPL as user interface, for tinkering, and that could be very interesting or clever. However, just to be clear to students and professionals who might stumble upon this thread... If I were actually doing this in production fo

Re: [racket] Puzzled about type inference

2014-08-03 Thread Matthias Felleisen
After some reflection, here is how I think you should proceed: #lang typed/racket (: 1+ (Nonnegative-Integer -> Positive-Integer)) (define (1+ n) (+ n 1)) ;; entirely unnecessary but helped me read (define-type (Maybe α) (U False α)) (define-type NI Nonnegative-Integer) (define-type LNI (Li

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Henry Lenzi
Oh, OK. :-) -- Henry On Sun, Aug 3, 2014 at 9:38 PM, Alexander D. Knauth wrote: > > On Aug 3, 2014, at 7:58 PM, Henry Lenzi wrote: > >> Alexander's idea is interesting, but it onlt works if the >> prescription file is not numbered (which is actually more natural), >> such as if it were: >> hctz

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Alexander D. Knauth
On Aug 3, 2014, at 7:58 PM, Henry Lenzi wrote: > Alexander's idea is interesting, but it onlt works if the > prescription file is not numbered (which is actually more natural), > such as if it were: > hctz25 30 pl 1xd > simva20 30 pl 1xn > >> (define in2 (open-input-file "Recipe3.txt")) >> (por

Re: [racket] Puzzled about type inference

2014-08-03 Thread Matthias Felleisen
In a sense, you put your finger on a sore spot of TR from R -- we are still figuring out how to help programmers along here. I rewrote your program like this: #lang typed/racket (: 1+ (Nonnegative-Integer -> Positive-Integer)) (define (1+ n) (+ n 1)) ;; entirely unnecessary but helped me r

Re: [racket] getting one macro to tell another macro to define something

2014-08-03 Thread J. Ian Johnson
This is why I tried a delta-introducer on between orig-stx (the syntax-time parameter in match) and mstx (in the application of the transformer), but even though the documentation for make-syntax-delta-introducer says it can take two arbitrary pieces of syntax to make an introducer, it barfs on

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Henry Lenzi
Alexander's idea is interesting, but it onlt works if the prescription file is not numbered (which is actually more natural), such as if it were: hctz25 30 pl 1xd simva20 30 pl 1xn > (define in2 (open-input-file "Recipe3.txt")) > (port->list (compose1 eval read) in2) '("Hydrochlorothiazide 25mg"

Re: [racket] Performance. Higher-order function

2014-08-03 Thread Matthias Felleisen
On Aug 3, 2014, at 6:29 PM, Richard Cleis wrote: > If I (define i->c integer->char), and use it in your test1, it becomes the > slowest. > That might mean that the "unknown function" response from Dr F applies to > your function, too. > In other words, I think this is another example of drawing

Re: [racket] getting one macro to tell another macro to define something

2014-08-03 Thread Alexander D. Knauth
I just thought: I could do syntax-local-introduce on the pattern before it gets passed to parse-id, and then do syntax-local-introduce on the bound-vars of that, except that it still doesn’t work. Well, I’m probably still missing the syntax-mark of the match*/derived form. Although I could wr

[racket] Puzzled about type inference

2014-08-03 Thread Norman Gray
Greetings. Short version: I repeatedly find myself adding TR type annotations by trial-and-error -- I'm sure I'm missing something. I had a particularly acute case of this this afternoon. I have a bit of typed/racket/base code as follows: (: 1+ (Nonnegative-Integer -> Positive-Integer)) (def

Re: [racket] Performance. Higher-order function

2014-08-03 Thread Richard Cleis
If I (define i->c integer->char), and use it in your test1, it becomes the slowest. That might mean that the "unknown function" response from Dr F applies to your function, too. In other words, I think this is another example of drawing ambiguous conclusions from tests that are too simple. I gav

Re: [racket] Teaching logical thinking via programming in Scheme

2014-08-03 Thread Matthias Felleisen
It seems to me that Igor Rivin's major flaw in thinking shows up on page 1 as a section title. In "The Consumer" the opinion piece makes the common mistake to introduce the undergraduate student as a consumer. He is not. The undergraduate student is the product that we, the professors, consume

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Alexander D. Knauth
On Aug 3, 2014, at 4:29 PM, Alexander D. Knauth wrote: > > On Aug 3, 2014, at 3:29 PM, Henry Lenzi wrote: > >> ; Hello all -- >> ; So here's how I solve all those little problems regarding symbols >> and evaluation of medication definitions. >> ; Would you please bear with me? I apologize for

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Henry Lenzi
Alexander -- Thanks. But what would "thing" be? On Sun, Aug 3, 2014 at 5:29 PM, Alexander D. Knauth wrote: > > On Aug 3, 2014, at 3:29 PM, Henry Lenzi wrote: > >> ; Hello all -- >> ; So here's how I solve all those little problems regarding symbols >> and evaluation of medication definitions. >

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Alexander D. Knauth
On Aug 3, 2014, at 3:29 PM, Henry Lenzi wrote: > ; Hello all -- > ; So here's how I solve all those little problems regarding symbols > and evaluation of medication definitions. > ; Would you please bear with me? I apologize for the length. > ; This is the approach I've taken. I've chosen no to

Re: [racket] Destructors in Racket

2014-08-03 Thread Gustavo Massaccesi
The difference is that every time that (list 1 2 3) is executed, you get a new different list. But with each '(1 2 3) you get every time the same list. The '(1 2 3) is referenced from the "source code" so it will not be collected. (A different copy of '(1 2 3) creates a different list, but always t

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Henry Lenzi
It's best if I use pasteracket ("Hank's medication thingy") http://pasterack.org/pastes/14535 -- Henry Lenzi On Sun, Aug 3, 2014 at 4:30 PM, Henry Lenzi wrote: > Uh oh, the GOOG botched formatting. Sorry about that! > > On Sun, Aug 3, 2014 at 4:29 PM, Henry Lenzi wrote: >> ; Hello all -- >> ;

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Henry Lenzi
Uh oh, the GOOG botched formatting. Sorry about that! On Sun, Aug 3, 2014 at 4:29 PM, Henry Lenzi wrote: > ; Hello all -- > ; So here's how I solve all those little problems regarding symbols > and evaluation of medication definitions. > ; Would you please bear with me? I apologize for the length

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-03 Thread Henry Lenzi
; Hello all -- ; So here's how I solve all those little problems regarding symbols and evaluation of medication definitions. ; Would you please bear with me? I apologize for the length. ; This is the approach I've taken. I've chosen no to use any macrology or parser/lexer technique because I don't

Re: [racket] getting one macro to tell another macro to define something

2014-08-03 Thread Alexander D. Knauth
Oh. I have no idea what to do then. I can’t even do syntax-local-introduce or (datum->syntax stx (syntax->datum stx)) on it because it’s not a syntax object. On Aug 3, 2014, at 1:59 PM, J. Ian Johnson wrote: > This is the problem of not introducing the right marks. He wants > (define-val

Re: [racket] getting one macro to tell another macro to define something

2014-08-03 Thread J. Ian Johnson
This is the problem of not introducing the right marks. He wants (define-values (x) (match blah [x x])) but is getting (define-values (x) (match blah [x-barf x])) Just pre-parsing won't get you all the way. You need to have a way to introduce to x-barf the marks between the outer match-define a

Re: [racket] getting one macro to tell another macro to define something

2014-08-03 Thread Alexander D. Knauth
But it was doing that already with no problem. All I _changed_ was that I added a syntax-property to pat so that it didn’t have to parse it more than once. Why would it work before but not with the syntax-property? On Aug 3, 2014, at 1:53 PM, Matthias Felleisen wrote: > > From where I si

Re: [racket] getting one macro to tell another macro to define something

2014-08-03 Thread Matthias Felleisen
From where I sit your syntactic abstraction generates code of this shape: ---> (define-values vars (match*/derived (rhs) #,stx [(pat) (values . vars ;; < This introduces vars ___and___ uses them before the right-hand side is evaluated. -- Matthias On Aug 3, 2014, at 1:50 PM, Alexan

Re: [racket] getting one macro to tell another macro to define something

2014-08-03 Thread Alexander D. Knauth
But I never defined or used those variables. All I did was save the parsed pattern in a syntax-property and have the parse function look at that syntax-property. On Aug 3, 2014, at 1:40 PM, Matthias Felleisen wrote: > > That means you are defining and using recursive variables before the

Re: [racket] getting one macro to tell another macro to define something

2014-08-03 Thread Matthias Felleisen
That means you are defining and using recursive variables before the initialization is done. On Aug 3, 2014, at 1:31 PM, Alexander D. Knauth wrote: > I tried it but got weird errors like this: > idle-rest: undefined; > cannot use before initialization > And this: > wrkr: undefined; > cannot

Re: [racket] getting one macro to tell another macro to define something

2014-08-03 Thread Alexander D. Knauth
I tried it but got weird errors like this: idle-rest: undefined; cannot use before initialization And this: wrkr: undefined; cannot use before initialization https://github.com/AlexKnauth/racket/compare/match-define-save-parsed-pattern On Aug 3, 2014, at 12:32 PM, J. Ian Johnson wrote: > Try i

Re: [racket] Teaching logical thinking via programming in Scheme

2014-08-03 Thread Matthias Felleisen
Thanks for pointing it out. Since the person is possibly still at Brown, I may try to contact him and see whether there is common ground. Much appreciated -- Matthias On Aug 3, 2014, at 12:26 PM, Bradley Lucier wrote: > Many people on this list think deeply about pedagogy; perhaps the follow

Re: [racket] Performance. Higher-order function

2014-08-03 Thread Matthias Felleisen
Because build-string calls an unknown function 1000 x 10 times, and an unknown function call is expensive. Racket could possible collapse all modules and perform additional in-lining optimizations eventually, which may help here. But it doesn't yet. -- Matthias On Aug 3, 2014, at 5:15

Re: [racket] getting one macro to tell another macro to define something

2014-08-03 Thread J. Ian Johnson
Try it and report back. -Ian - Original Message - From: "Alexander D. Knauth" To: "J. Ian Johnson" Cc: "racket users list" Sent: Sunday, August 3, 2014 12:22:57 PM GMT -05:00 US/Canada Eastern Subject: Re: [racket] getting one macro to tell another macro to define something What if ma

[racket] Teaching logical thinking via programming in Scheme

2014-08-03 Thread Bradley Lucier
Many people on this list think deeply about pedagogy; perhaps the following article published in the Notices of the American Mathematical Society, which advocates teaching logical thinking via Scheme programming before advancing to the usual university mathematics curriculum (calculus, etc.), ma

Re: [racket] getting one macro to tell another macro to define something

2014-08-03 Thread Alexander D. Knauth
What if match-define did something like this to store the parsed pat in a syntax-property?: (define-syntax (match-define stx) (syntax-parse stx [(_ pat rhs:expr) (let ([p (parse-id #'pat)]) (with-syntax ([pat (syntax-property #'pat 'parsed-pat p)]

[racket] Performance. Higher-order function

2014-08-03 Thread Roman Klochkov
Are higher order function always slow? Made small test: test1 -- unfamous set-in-the-loop accumulating test2 -- built-in build-string test3 -- manually written build-string with the same code as in test1 (define (test1 n) (define res (make-string n))     (for ([i (in-range n)])         (stri