-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Description
My specific encounter was implementing a ghetto switch-case #31 like so:
let( match = something
cases = some* thing onething $match #last one is 'default'
bodies = ( {echo this is something}
{echo this is thing}
{echo this is onething}
{echo reached default} ))
for (case = $cases; body = $bodies) if {~ $match $case} $body
but this will echo reached default because 'some*' won't be expanded inside the tilde-match statement.
this is good behaviour of course, but my question is do we have an idiomatic way to override it?
AFAIK there's no expand primitive, and eval would try to run the pattern as a command.
Perhaps the only answer is eval '{~ $match '$case'}', but I wonder if there's something more general to expand quoted patterns without necessarily running a command on them under eval..
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels