Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005232OCamlOCaml generalpublic2011-02-26 21:362014-10-31 09:41
Reporterygrek 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusconfirmedResolutionopen 
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.
Tagsjunior_job
Attached Files

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

-  Notes
(0009946)
gasche (developer)
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?
(0009959)
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.
(0009962)
gasche (developer)
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).

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

Seems related to 0006631
(0012478)
gasche (developer)
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.


- 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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker