Expression Bodies (Command Chaining)

Issue #54 resolved
Yusuf Ismail repo owner created an issue

Propose the two commands

mul x y
set-hp val

With command chaining you would be able to do

set-hp mul(5 20)

Whilst the specific syntax is just a proposal, the overall idea is that commands should be able to be chained, so that the output of one can be used as the input of another. This could allow very powerful constructs

Naturally, type checking and error handling will need to be performed for the data passing

Comments (9)

  1. Yusuf Ismail reporter

    Another syntax proposal would be a much more explicit expression body style

    set-hp {mul 5 20}
    set-hp {add {get-hp} 10}
    
  2. Yusuf Ismail reporter
    • changed status to open

    Expression bodies are now functional, however they do not yet work for recursive inner arguments

    For example

    sort<int> [1, {expr}, 2]
    

    will fail

  3. Yusuf Ismail reporter

    Expression bodies now disallow null values, unless specified as nullable with {expr}?

    Non-nullable expression bodies will complain if the resulting value is null

  4. Yusuf Ismail reporter

    Expression bodies do not yet work when the type can be converted but is not directly assignable. i.e `{expr}` returns an int, but the command expects a float will be incorrectly recorded as incompatible

  5. Yusuf Ismail reporter

    Type compatibility is now properly fixed. The only (known) issue remaining is when the expr body is encountered in some kind of nested object (such as an array. An expression body containing other expression bodies works fine)

  6. Yusuf Ismail reporter

    This is now fully supported, and along side boolean negation is implemented using the new IQcGrammarConstruct system

  7. Log in to comment