LightAndLight / ipso

A functional scripting language.
https://ipso.dev
17 stars 1 forks source link

`--script` flag #133

Open LightAndLight opened 2 years ago

LightAndLight commented 2 years ago

Depends on #74.

When --script is set, the entire file is treated as a comp expression defining the IO action to run.

e.g.

#! /usr/bin/env -S ipso --script

println "hello, world!"

is equivalent to

#! /usr/bin/env ipso

main : IO ()
main =
  comp
    println "hello, world!"
LightAndLight commented 2 years ago

This file has a different syntax to non-script files. Something like:

script_file ::=
  script_line+

script_line ::=
  import
  from_import
  comp_expr_line

Make sure there are datatypes that reflect this.

LightAndLight commented 2 years ago

I don't like that users of env would have to add the -S option to use this feature.

Maybe a busybox-style approach would be useful. When ipso looks at argv[0] and sees that it's called as ipso-script, it behaves as if the --script option were set.

#! /usr/bin/env ipso-script

println "hello, world!"

This introduces a new problem: making sure the user has an ipso-script symlink on their system.