On Mon, Aug 11, 2014 at 8:07 AM, Matthew Flatt wrote:
> +1
>
> In the grand scheme of things, using `eval` to solve a problem (because
> you want to get something done now) is nowhere near as bad as, say,
but, to come back to the original question, in order to not confuse
further the OP: in this
+1
In the grand scheme of things, using `eval` to solve a problem (because
you want to get something done now) is nowhere near as bad as, say,
using/building an interpreter that is implemented in C (because I want
to get something done "now", circa 1995).
:)
At Sun, 10 Aug 2014 10:38:24 -0400, S
***The ultimate (programming) concern is what will produce the highest
average correct-and-useful-running-program-output per second over my
lifespan.***
(philosophical extensions: provided it doesn't hurt other people, unless
they are "bad", where bad = ...etc...)
Or anyone else who programs. The
On Sun, Aug 10, 2014 at 3:59 AM, Matthew Flatt wrote:
>
> It's true that `eval` works as way to get reflective operations in
> general, but it's better (again, for error checking and for
> efficiency) when a language construct is accompanied with specific
> reflective operations. [...] But if `ke
On Sat, Aug 9, 2014 at 8:27 AM, Neil Van Dyke wrote:
> Sounds like a good rule of thumb. Two suggestions to add:
>
> * Maybe there could also be a second rule of thumb, like, "If you need
> arbitrary Racket expressions, then consider whether you can do it
> with one of the following patterns:
I think you're looking for `keyword-apply`.
It's true that `eval` works as way to get reflective operations in
general, but it's better (again, for error checking and for efficiency)
when a language construct is accompanied with specific reflective
operations. In the case of keyword arguments, tho
Just for fun, I made a function to do this the “non-eval” way, and it was more
complicated than I would have thought, although maybe I was overcomplicating it
a bit?
https://github.com/AlexKnauth/hash-lambda/blob/master/keyword-lambda/kw-apply.rkt
On Aug 9, 2014, at 10:10 AM, Sean Kanaley wro
Sorry, couple typos: mapply = map and l = lst.
On Sat, Aug 9, 2014 at 10:10 AM, Sean Kanaley wrote:
> There's a simple enough example I think: apply with keyword parameters.
> Apply has that built-in..sort of...but the list is supposed to be provided
> inline to APPLY, seemingly requiring apply
There's a simple enough example I think: apply with keyword parameters.
Apply has that built-in..sort of...but the list is supposed to be provided
inline to APPLY, seemingly requiring apply to be applied (e.g. (apply apply
(cons *thefunctiontoapply* params))), except keywords can't be expressions
a
Sounds like a good rule of thumb. Two suggestions to add:
* Maybe there could also be a second rule of thumb, like, "If you need
arbitrary Racket expressions, then consider whether you can do it with
one of the following patterns: [list some patterns involving
combinations of syntax extension
I think that I ran into a nice way to discourage eval except when
needed: the rule of thumb is to only use eval when you need to evaluate
any arbitrary (Racket) expression. It sounds simplistic but it covers
lots of cases that make newbies run to eval:
* I just want to get the value of a variable
Henry Lenzi wrote at 08/04/2014 07:43 PM:
By the way, if you guys had any idea of the buggy stuff people sell to
the health sector. The atrocious VB, MFC C++, Java... I'm not even
goint to mention security..
Heh. I have seen some of that, and actually suggested to one of my
consulting clients
Henry Lenzi wrote at 08/04/2014 07:21 PM:
I was just wondering, Neil. what your experience in "production for
pharmaceutical prescriptions/labeling/instructions" software would be.
I'd be glad to read some stuff you've published or other software
solutions, if it's not proprietary software. If i
Hi Neil --
Thanks for the answer.
Let's see...
* Prevents much static checking. > not really an issue in this
case (I don't see it).
* Likely increased difficulty debugging ---> true.
* Often executes arbitrary code with privileges, which might be
corrupted due to accident or attack, which c
I was just wondering, Neil. what your experience in "production for
pharmaceutical prescriptions/labeling/instructions" software would be.
I'd be glad to read some stuff you've published or other software
solutions, if it's not proprietary software. If it is, what companies
have you worked for in
Oh sorry I meant this for parse-meds:
(define (parse-meds lst)
(match lst
[(list) ""]
[(list-rest MED QUANT FORM POS (? inst? INST) rest)
(~a MED " " line " " QUANT " " FORM "\n" POS "\n" INST "\n" (parse-meds
rest))]
[(list-rest MED QUANT FORM POS rest)
(~a MED " " line "
Then would something like this work?
#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 (displayln (parse-meds (list med-thing ...)
(define (parse-med
On Aug 4, 2014, at 6:00 AM, Neil Van Dyke wrote:
>
> Matthew Flatt wrote at 08/04/2014 02:40 AM:
>> While he didn't say so explicitly, I don't think that Neil is worried
>> about the implementation of `eval` within Racket. After all, `eval` is
>> at the heart of the implementation, and any prog
Matthew Flatt wrote at 08/04/2014 02:40 AM:
While he didn't say so explicitly, I don't think that Neil is worried
about the implementation of `eval` within Racket. After all, `eval` is
at the heart of the implementation, and any program that you give to
Racket is going through `eval` whether or
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
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
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
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 " "
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
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
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
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
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
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"
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
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.
>
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
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 --
>> ;
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
; 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
Hello everyone -
First of all, a big Thank You to all of you and for taking the time for
responding.
I'll have to set aside sometime during this weekend to see if I can
understand the ideas you've been so kind to offer.
However, I should confess that I've made some progress with way simpler
stuf
At Wed, 30 Jul 2014 22:57:59 -0300,
Henry Lenzi wrote:
> This might lead to having hundreds of definition files, however (say,
> one for each medication defintion).
If you want. You can have as many definitions per file as you'd like,
though, so you don't have to.
When you import a module, all it
On Jul 30, 2014, at 9:57 PM, Henry Lenzi wrote:
> This might lead to having hundreds of definition files, however (say,
> one for each medication defintion).
Use sub-modules and load them:
#lang racket
(module prescription1 PPL ...)
(module prescription2 PPL ...)
etc.
Your PPL (prescri
Hi Henry
I'm taking a similar approach to Galler for a proof-of-concept, but without
the macrology. This should make the ideas more widely accessible (and my
skill with macros is limited).
First, thank-you again for supplying the example. By comparing input and
output readers can infer the kinds
Henri
Is this what you're after?
#lang racket/base
(require (for-syntax syntax/parse
racket/base
))
(provide make-script)
(begin-for-syntax
(define-syntax-class unit-dictionary
#:attributes (str)
(pattern (~literal p)
#:wit
How do you tell Racket Scheme to save a module (programatically, that
is)? I only see syntax for importing modules in the documentation.
Is that even possible?
TIA,
Henry
On Mon, Jul 28, 2014 at 6:03 PM, Vincent St-Amour wrote:
> Henry,
>
> It looks like modules may be what you're looking for.
Actually, it occurred to me that re-assembling the symbols in the
recipe/module might involve macrology, in order to put in the
following format:
MEDICATION QUANTITY LINE NUMBER FORM
INSTRUCTIONS
(that's like OMZ20 30CP INSTOMZ that I exemplified in another message,
expanding to:
Omeprazol 20mg
Actually, this is interesting.
This might lead to having hundreds of definition files, however (say,
one for each medication defintion).
I would have to look into how I can save a module to a file (Alexander
Knauth explained that (write '(define hctz25 "Hydrochlorothiazide
25mg") out) would write
Hi Dan --
What you saw was precisely the database file (it's a file written in
the programming language FORTH).
Cheers,
Henry
On Wed, Jul 30, 2014 at 10:48 PM, Daniel Prager
wrote:
> Thanks Henry
>
> That's exactly what I was interested in. I'm at work at the moment
> (Australia), but will have
Thanks Henry
That's exactly what I was interested in. I'm at work at the moment
(Australia), but will have a bit more of a look later tonight
But I have an interest in the health sector, and would be interested in
contributing to a public domain project, especially if we can make
something neat /
Yes, I do, as physician.
This is all internal, nothing is or will be published (but I wouldn't
care/mind releasing the code, when and if I have it). The way to think
of this is: I could be typing stuff out on Word, or I could use the
hospital's buggy and horrible software. But I'll just roll my ow
Hi Henry: do you work in the heath system? If you have any pointers
I'd be interested to read about your work and how you use things like
Forth (or maybe someday, Racket! :) in that work.
Best,
Robby
On Wed, Jul 30, 2014 at 7:49 PM, Henry Lenzi wrote:
> Hi Daniel --
>
> Do you mean the Forth fil
Hi Daniel --
Do you mean the Forth files?
I don't belienve they would make much sense to you, but it would go
something like this (as you can see, that is a FORTH definition):
: NAME S"John Doe"
CU4
HCTZ25 30P 1CPM
OMZ20 30P 1CPM INSTOMZ
SIMVA20 30P 1CPN
L\D ;
Expands to (NOTE: S
Hi Henry
Racket is very suitable for writing DSLs, or even whole Ls (more
advanced!). As you'd expect, the idioms for DSL construction in straight
Racket are different from those in Forth and will take a bit of
familiarization and adjustment.
Would you be willing to share a more fully-fledged exa
On Jul 29, 2014, at 11:42 PM, Henry Lenzi wrote:
> (read in) doesn't work.
>
> This should be simple...I write
>> (define out (open-output-file "Recipe.txt"))
>> (print *med-name* out)
What you probably want here is write, not print.
>> (close-output-port out)
Print is good for printing values
>
> Thanks, Vincent. But a recipe is more than those simple definitions.
> Actually, it would be something like:
> MEDICATION DOSE UNITS - QUANTITY FORM
> INSTRUCTIONS FOR TAKING MEDICATION
The module idea would still work. You can define your definitions in one
file, provi
(read in) doesn't work.
This should be simple...I write
> (define out (open-output-file "Recipe.txt"))
> (print *med-name* out)
> (close-output-port out)
and what I see in the file is:
'hctz25
How can I import this from a file?
If I use (read in), I get:
''hctz25
(two quotes)
The issue here w
Thanks, Vincent. But a recipe is more than those simple definitions.
Actually, it would be something like:
MEDICATION DOSE UNITS - QUANTITY FORM
INSTRUCTIONS FOR TAKING MEDICATION
In my previous Forth version, this was extremely easy to achieve, as
Forth is syntax-less, and
I don’t think you even need to serialize it for that:
(define my-hash (make-hash))
(define out (open-output-file “dump.dat”))
(write my-hash out)
(close-output-port out)
… later
(define in (open-input-file “dump.dat”))
(define my-hash (read in))
(close-input-port in)
On Jul 28, 2014, at 11:59 PM,
You may also export all hash to file and later read it.
http://docs.racket-lang.org/reference/serialization.html
(require racket/serialize)
(define my-hash (make-hash))
(define out (open-output-file "dump.dat"))
(write (serialize my-hash) out)
(close-output-port out)
... later
(define in (ope
If we keep a human in the loop, we can see how users respond to the
different messages, and adapt our form of expression as necessary. If
all else fails, the nuclear option: viral YouTube video of "Don't use
eval" as interpretive dance.
Neil V.
Matthias Felleisen wrote at 07/28/2014 02:46 PM:
Neil, I think that would be a wonderful service that you could script as a
little Racket daemon. It could broadcast this message every quarter or so (as
an addendum to PLT Design Inc's financial statement) and the broadcast could
take different shapes and forms and use different words (FAQ, TLL
On Jul 28, 2014, at 4:21 PM, Henry Lenzi wrote:
> Hi Neil --
>
> So how do you export hash keys as symbols to a file that can be read
> in again, not as string?
>
> Now, I haven't gotten around to reading the whole of Racket Scheme's
> documentation... Things are looking kind of hard.
>
> Wha
Henry,
It looks like modules may be what you're looking for.
You could have a file that defines a substance and exports it
;; a.rkt
#lang racket
(provide hctz25)
(define hctz25 "Hydrochlorothiazide 25mg")
and then a recipe file that imports the previous file
#lang racket
Hi Neil --
So how do you export hash keys as symbols to a file that can be read
in again, not as string?
Now, I haven't gotten around to reading the whole of Racket Scheme's
documentation... Things are looking kind of hard.
What I'm attempting to do is then read back the symbols defined, such
as
I don't know the current state of the "eval" docs in the manual, but I
think they should have a big warning at the very front, intended to
scare away newbies.
Remember that Racket is often used in conjunction with many different
Scheme-based and other Lisp-based textbooks and courses. It seems
Hello again-
I suppose this doesn't look like a case for eval when you first look into
it, but since I would like to export the shorthand symbols to a file, I
just might need eval.
- Henry.
Em domingo, 27 de julho de 2014, Pierpaolo Bernardi
escreveu:
> On Sun, Jul 27, 2014 at 5:10 AM, Henry L
Em domingo, 27 de julho de 2014, Matthew Butterick escreveu:
> Because *med-name* is different. The other three are the names of
> variables that hold strings. But *med-name* is the name of a variable that
> holds the name of another variable that holds a
>
> Yes, always good to be reminded about
Maybe this should be linked to from the `eval' docs?
http://blog.racket-lang.org/2011/10/on-eval-in-dynamic-languages-generally.html
Vincent
At Sun, 27 Jul 2014 16:16:52 -0400,
Neil Van Dyke wrote:
>
> Maybe there should be a periodic public service announcement about not
> using "eval". This
Maybe there should be a periodic public service announcement about not
using "eval". This time I will communicate in FAQ format:
Q: How do I use eval?
A: Don't use eval.
Q: But don't so many academic books feature eval prominently, so doesn't
that mean I should use try to eval?
A: Those books
By the way, just out of curiosity, why do I need to nest EVALs.
E.g., this won't work (notwithstanding the namespace issue in the
definitions panel, just using the REPL):
> (map eval '(*med-name* line *quant-str* pl))
'(hctz25 "---" "30" "pills")
Why wasn't the symbol "hctz25" expanded? I
Thanks for your answers.
- Henry Lenzi
On Sun, Jul 27, 2014 at 2:36 AM, Matthew Butterick wrote:
> The REPL automatically uses the current namespace, which is why you can
> casually use eval there without specifying a namespace. [1]
>
> But if you're using eval in the definitions window, you nee
The REPL automatically uses the current namespace, which is why you can
casually use eval there without specifying a namespace. [1]
But if you're using eval in the definitions window, you need to give it a
namespace, otherwise you'll get "unbound identifier" errors.
In this case, the namespace
On Sun, Jul 27, 2014 at 5:10 AM, Henry Lenzi wrote:
> #lang racket
>
> #|
>
> Dear Racketeers -
>
> I would like to create a little function
> that would write a line of a medical recipe.
>
> I would pass to "read" a shorthand form,
> and the program would expand the text. Like so:
>
> When I answ
69 matches
Mail list logo