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

Get rid of special *in* variable (BREAKING!) #173

Closed
borkdude opened this issue Dec 19, 2019 · 0 comments
Closed

Get rid of special *in* variable (BREAKING!) #173

borkdude opened this issue Dec 19, 2019 · 0 comments

Comments

@borkdude
Copy link
Collaborator

borkdude commented Dec 19, 2019

The name *in* now collides with clojure.core/*in*, an unforeseen problem when babashka was initially just designed to deal with small one-line snippets. The value *in* is really a delay which, when realized, reads a line of text or EDN value from stdin. We will remove this magic behavior and expose user/stdin as a delay that users could have written themselves in normal Clojure.

This is a reaction to #171.

Option 0:
Only rename, no other changes, leave the magic.
The new syntax becomes:

$ echo 'hello' | bb 'stdin'
hello

or:

$ echo 'hello' | bb '<stdin>'
hello

(or some other name that we like best).

This option is the least breaking one.

Option 1:
The new syntax becomes:

$ echo 'hello' | bb '@stdin'
hello

We're not hiding the fact that we're using a delay in the implementation.

Option 2:
Deprecate a special variable for stdin. We have read-line anyway. But what do we do for reading EDN? People should use (edn/read *in*)?

$ echo 'hello\nthere' | bb '[(read-line) (read-line)]'
["hello" "there"]

For reading all EDN values from stdin:

$ echo '{:a 1} {:a 2}' | bb -e '(vec (take-while #(not= % ::eof) (repeatedly #(edn/read {:eof ::eof} clojure.core/*in*))))'
[{:a 1} {:a 2}]
@borkdude borkdude changed the title Rename user/*in* to user/stdin and don't hide that it's a delay Rename user/*in* to user/stdin and don't hide that it's a delay (BREAKING!) Dec 19, 2019
@borkdude borkdude changed the title Rename user/*in* to user/stdin and don't hide that it's a delay (BREAKING!) Get rid of special *in* variable (BREAKING!) Dec 19, 2019
borkdude added a commit that referenced this issue Dec 19, 2019
borkdude added a commit that referenced this issue Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant