Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005232OCamltoplevelpublic2011-02-26 21:362017-03-03 17:11
Assigned To 
PlatformOSOS Version
Product Version3.12.0 
Target VersionFixed in Version 
Summary0005232: wish: -str option for ocaml
DescriptionSometimes it is useful to be able to run simple oneliner ocaml code without writing the code previously to file. Option -str analoguos to one of camlp4 is wanted.
Attached Files

- Relationships
related to 0000352closeddoligez have ocaml support the '-' option (for standard input) 
related to 0006071closedgasche ocaml (toplevel) should have a -no-init option 
has duplicate 0006631closedgasche ocaml -e 'Printf.printf "hello\n"' 

-  Notes
gasche (administrator)
2013-07-28 22:42

I think that this feature doesn't really work:
- the compilers (ocamlc and ocamlopt) need the filename to be used as a compilation unit name, so simply passing code in -str wouldn't work (except if this is only intended for parsing/typing with option -i?)
- the toplevel already makes it easy to work with short pieces of code (in particular `cat "foo;;" | ocaml`), so I'm not sure an -str option to ocaml would make much sense.

ygrek, could you be more specific on the use-cases and semantics you had in mind?
ygrek (reporter)
2013-07-29 04:36

yes, this was intended exactly as a shorthand for toplevel, but with the following implied features : be usable as script runner, i.e. no extra toplevel output (prompts and types), stdin available for input (with toplevel it results in End_of_file), no reading of ocamlinit (not sure about this one). The intended use-case - running some automated utility tasks (inside project directory) where the actual code is available in a cma or ml file and one-liner is needed to actually call it or run with specific parameters.
gasche (administrator)
2013-07-29 07:15
edited on: 2013-07-29 18:35

Thanks for the additional information. That seems reasonable. I think it's also reasonable to not run the .ocamlinit, because the "-stdin" option already doesn't do that. In fact I suspect they should both read .ocamlinit, and have a -noinit option (can be obtained as -init /dev/null right now), but that's question that can be handled independently (in fact it is an existing PR: PR#6071).

kyoDralliam (reporter)
2014-10-29 22:28

Seems related to 0006631
gasche (administrator)
2014-10-31 09:41
edited on: 2014-10-31 09:42

Indeed; kyoDralliam, could you repost your patch here, using `-str` rather than `-e`?

PS: in case the patch is merged, the name you use in your .patch would be used as attribution information.

shinwell (developer)
2016-12-13 11:47

@gasche Could you take care of these two issues?
gasche (administrator)
2017-03-03 17:11

The patch is not good enough (for example it creates a temporary file but never deletes it, littering the user's filesystem with useless source files) and I had no feedback/return from the contributor. I can't spend time making a better patch right now, so as far as I am concerned the feature request is still standing, and any user's contribution is welcome.

- Issue History
Date Modified Username Field Change
2011-02-26 21:36 ygrek New Issue
2011-05-17 15:42 doligez Status new => acknowledged
2013-07-28 22:42 gasche Note Added: 0009946
2013-07-28 22:42 gasche Assigned To => gasche
2013-07-28 22:42 gasche Status acknowledged => feedback
2013-07-29 04:36 ygrek Note Added: 0009959
2013-07-29 04:36 ygrek Status feedback => assigned
2013-07-29 07:04 gasche Tag Attached: junior_job
2013-07-29 07:04 gasche Assigned To gasche =>
2013-07-29 07:15 gasche Note Added: 0009962
2013-07-29 07:15 gasche Status assigned => confirmed
2013-07-29 07:16 gasche Relationship added related to 0000352
2013-07-29 18:35 gasche Note Edited: 0009962 View Revisions
2013-09-18 16:37 lpw25 Relationship added related to 0006071
2014-10-29 22:28 kyoDralliam Note Added: 0012468
2014-10-31 09:40 gasche Relationship added has duplicate 0006631
2014-10-31 09:41 gasche Note Added: 0012478
2014-10-31 09:42 gasche Note Edited: 0012478 View Revisions
2016-12-13 11:47 shinwell Note Added: 0016994
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 16:08 doligez Category -OCaml general => toplevel
2017-03-03 17:11 gasche Note Added: 0017562

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker