From: jehenrik <jehenrik@yahoo.com>
To: caml-list@inria.fr
Subject: [Caml-list] camlp4: ONCE construct
Date: Fri, 10 Jan 2003 14:14:14 -0500 [thread overview]
Message-ID: <B4EFF544-24CF-11D7-B29E-00039375801A@yahoo.com> (raw)
Hi,
I would like to write a Camlp4 construct which causes its argument to
only be evaluated once. Eg:
...
...
...
ONCE Pcre.regexp "([0-9]+)"
would be transformed to:
let gensym000 = Pcre.regexp "([0-9]+)";;
...
...
...
gensym000
but I don't see a way to get a nonlocal transformation like that. One
way would be if the system had a way to side-effect out a new toplevel
let while the expressions were transforming. I suspect that facility
does not exist. Another way would be to have a second keyword
(ONCEBLOCK or something?) that would go where the let bindings
eventually would, which could take as an argument the entire expression
tree containing ONCE declarations. Then after a complicated recursive
parse on all the syntactic constructs, all the ONCEs could be located,
enumerated, and removed.
Note that I don't want to "memoize," or create a thunk which when
evaluated the first time does something complicated and all subsequent
times remembers what it did the first time. That still requires
manually writing the let statements in a different code location. My
goal is to improve readability by putting my regexps where they matter,
not several screens up just so that they get cached at runtime.
Thanks for any advice,
Jeff Henrikson
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next reply other threads:[~2003-01-10 19:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-10 19:14 jehenrik [this message]
2003-01-10 22:35 ` Yutaka OIWA
2003-01-11 1:23 ` jehenrik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B4EFF544-24CF-11D7-B29E-00039375801A@yahoo.com \
--to=jehenrik@yahoo.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox