Quoted var assignment
See original GitHub issueTo be able to use var
we need to extend Expr[T]
with a VarExpr[T]
that allows the expression to be used in the left-hand side of an expression.
def whileNotZero(body: VarExpr[Int] => Expr[Unit]) = '{
var x = 0
while (x == 0) ~body('(x))
}
whileNotZero(x => '{ ~x = ~x - 1 })
Currently in '{ ~x = ~x - 1 }
, the left hand side cannot be spliced in. The VarExpr[T]
would allow x to be spliced on the left hand side of the assignment.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Are quotes needed for local variable assignment?
Quotes are needed in export foo="$var" or local foo="$var" (or readonly , typeset , declare and other variable declaring commands) in:.
Read more >bash - Quoting vs not quoting the variable on the RHS of a ...
I think there is no big difference here. Yes, it is advisable to enclose a variable in double quotes when that variable is...
Read more >4.2. Variable Assignment
Variable Assignment. = the assignment operator (no space before and after) ... tabs and newlines. echo echo "$a" # The quoted variable preserves...
Read more >Forgetting Quotes Leads to “command not found” on ... - O'Reilly
Your script is assigning some values to a variable, but when you run it, the shell reports “command not found” on part of...
Read more >Understanding Shell Script Variables
This assigns the string "Hello World" to the variable MY_MESSAGE then echo es out the value of the variable. Note that we need...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
An alternavie library implementation is possible
But there is a bug when splicing
~e
, it emits an error withvalue 'apply' is not a member of scala.quoted.Expr[Unit]
(see #4044).Fixed by #4081