-
Notifications
You must be signed in to change notification settings - Fork 13
Batch Script Implementation
Any arithmetic operations need to be prefixed with /a
.
SET /a (2+2)*2
=> 8
This means we must have prior knowledge that we are dealing with numbers with a set!
.
(set! x (+ 1 1))
=>
SET /a x=(1+1)
The below case needs to be discerned from the above.
(set! x "string")
=>
set x=string
Currently the (+ 1 1)
is converted to (1+1)
but there is no way for the set!
command to know when to slot in an /a
.
Use an intermediate parsing phase.
(set! x (+ 1 1))
=>
(set-arith! x (+ 1 1))
=>
SET /a x=(1+1)
Functions in batch are named with a label prefixed by :
.
To call a function the CALL
command is used. Unfortunately, this command is overloaded to also call internal commands.
CALL :Function1
CALL echo after function call
:Function1
echo this is an example function
GOTO :End
:End
=>
this is an example function
after function call
In Stevedore it might look like this:
(script
(defn asdf []
(echo "this is an example function"))
(asdf)
(echo "after the function call"))
There is however some ambiguity as to what (asdf)
could mean in batch (either call asdf
or call :asdf
). There is no such ambiguity in Bash as commands and functions have the same syntax.
(script
(defn :asdf []
(echo "this is an example function"))
(:asdf)
(echo "after the function call"))
+ve
- No ambiguity in batch
- bash could just parse out the semicolon prefix
-ve
- Illusion of declaring first class functions (in the bash sense) is lost.
Overall, an unsatisfactory solution.