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

Oil language syntactic/semantic issues #477

Closed
12 of 14 tasks
andychu opened this issue Sep 7, 2019 · 2 comments
Closed
12 of 14 tasks

Oil language syntactic/semantic issues #477

andychu opened this issue Sep 7, 2019 · 2 comments

Comments

@andychu
Copy link
Contributor

andychu commented Sep 7, 2019

  • what is the exit status of var, setvar, func, proc, etc. ? Sometimes we die hard, but sometimes return 1 and let errexit take care of it. (moved to test and document var x = $(false) #942
    • note that inline function calls may fail in the middle of a command
  • What's the exit status of a block? -- blocks don't have exit status, commands do
  • But what about the exit status of the builtin that calls the block?
    • cd, shopt, shvar, env, etc. -- it's generally 0; failure can be handled in the block
  • should there be lexical scope ? (deferred)
  • Should setvar / set respect dynamic scope?
    • or only modify locals and globals, with do setvar(name, val, up=1) for modifying up the stack?
    • note that LookupVar in oil_lang/expr_eval.py only looks up locals and globals
    • maybe you need setglobal too?
  • var sum = 1 fails because sum() function already exists. Maybe only check locals. Globals are OK to shadow.
    • fixed after changing var / const / setvar semantics
  • errors and exceptions -- try/catch, or anything else?
    • mostly fixed with if try
  • how to throw away return value? e.g. = myfunc() without pretty printing.
    • can't use do, pass is discouraged.
    • solution: _ myfunc()
  • block syntax: change it to x = ^( echo hi ), and dicts should go back to {} so they're consistent with every other language, and JSON
  • Should break and continue be allowed within blocks?

Example:

for x in 1 2 3 {
  cd /dir-$x {
     break  # probably don't want this?
  }
}

Syntax

  • "$len(x)" should be an error, because ( isn't respected?
    • "${len}(x)" is the unambiguous way to write it.
    • ${len(x)} will be accepted
  • what to do about singleton tuples? (resolved)
    • tup(42)
  • x = class is invalid -- do we need a different way to handle keywords? I think so
  • back out of div / mod / xor ? To match Python / C++ / Tea
  • ++ operator for concatenation

Shell Collisions

  • if ((0,0) > othertuple)) { isn't parsed right!
    • probably need a parse_legacy mode or something. Maybe the new lex_mode_e.OilCommand mode will disallow it. (OilCommand lexer mode #630)
@andychu andychu changed the title Oil language semantic issues Oil language syntactic/semantic issues Sep 7, 2019
@andychu
Copy link
Contributor Author

andychu commented Sep 15, 2019

I think it should be:

  • Tuple([1, 2, 3]) -- takes an arbitrary iterable
  • tup() -- empty tuple
  • tup(x) -- singleton tuple

andychu pushed a commit that referenced this issue Apr 27, 2022
This was partially tested in spec/oil-blocks.test.sh but not completely.

Also test out the exit status of blocks.

Part of #477.
andychu pushed a commit that referenced this issue Apr 28, 2022
Also document block control flow semantics.  Part of #477.

- A spec test for command_sub_errexit
- More tests for 'try'
@andychu
Copy link
Contributor Author

andychu commented May 21, 2022

Hmm everything here is taken care of or moved to another issue!

@andychu andychu closed this as completed May 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant