Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wish: -str option for ocaml #5232

Open
vicuna opened this Issue Feb 26, 2011 · 7 comments

Comments

Projects
None yet
1 participant
@vicuna
Copy link
Collaborator

vicuna commented Feb 26, 2011

Original bug ID: 5232
Reporter: @ygrek
Status: confirmed (set by @gasche on 2013-07-29T05:15:41Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.12.0
Category: toplevel
Tags: junior_job
Has duplicate: #6631
Related to: #2757 #6071
Monitored by: @gasche @ygrek

Bug description

Sometimes 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.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Jul 28, 2013

Comment author: @gasche

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?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Jul 29, 2013

Comment author: @ygrek

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.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Jul 29, 2013

Comment author: @gasche

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: #6071).

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Oct 29, 2014

Comment author: kyoDralliam

Seems related to #6631

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Oct 31, 2014

Comment author: @gasche

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.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Dec 13, 2016

Comment author: @mshinwell

@gasche Could you take care of these two issues?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Mar 3, 2017

Comment author: @gasche

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.