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

support one liners with #? braces syntax #5

Closed
timotheecour opened this issue Apr 7, 2018 · 6 comments
Closed

support one liners with #? braces syntax #5

timotheecour opened this issue Apr 7, 2018 · 6 comments

Comments

@timotheecour
Copy link
Contributor

timotheecour commented Apr 7, 2018

1 liners are very useful for REPL, otherwise cmd recall is kind of broken.

braces syntax allow arbitrary nim code to fit in 1 line.

eg:
>>> proc fun(a:int): auto {return a*2}

implementation:
using undocumented(?) ``#? braces` syntax

eg:
foo.nim

#? braces

proc main() {
  echo "Hello"
}

when (isMainModule) {
  main()
}

this mode could be enabled via a meta option, see #6, eg :brace=on or :brace=off

@ghost
Copy link

ghost commented May 12, 2018

@AndreiRegiani I think this should be closed because syntax skins were removed from Nim (devel), so they'll not be available in the next Nim stable version.

@AndreiRegiani
Copy link
Member

@Yardanico Thanks for the insight!

@timotheecour from your example, currently we can do it:

>>> proc fun(a: int): auto = return a*2
>>> fun(10)
20 : int

Can also do multiple statements using ;

>>> echo 1; echo 2; echo 3
1
2
3

e.g.

>>> proc moreFun(a, b: int): auto = echo 1; echo 2; echo 3; return a * b
>>> moreFun(2, 5)
10 : int

it seems we don't need syntax skins, right?

@ghost
Copy link

ghost commented May 12, 2018

@AndreiRegiani well, you wouldn't be able to write two procedures on one line, but I don't think someone will try that.

@juancarlospaco
Copy link

I think with arrow function from future you can write 2 proc on 1 line.

I didnt know skins gonna be removed.

@ghost
Copy link

ghost commented May 13, 2018

@juancarlospaco future module was renamed to sugar because it's just sugar. And no, you can't write two procs on one line with it.

@juancarlospaco
Copy link

This should be closed, the braces skin is dead.

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

3 participants