Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Case statement with ";|" [not implemented]
- X-seq: zsh-users 11134
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Case statement with ";|" [not implemented]
- Date: Thu, 18 Jan 2007 20:52:43 -0800
- In-reply-to: <e5d50bd20701181153j4ac7faeajd0ec871ea02af518@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <e5d50bd20701181153j4ac7faeajd0ec871ea02af518@xxxxxxxxxxxxxx>
On Jan 18, 11:53am, Gerald Lai wrote:
}
} My question is, shouldn't there be a way to do this:
} ===
} case $mycase in
} 0)
} echo "mycase is 0"
} ;;
}
} 1)
} echo "mycase is 1"
} ;|
}
} 2)
} echo "mycase is 2"
} ;|
}
} *)
} echo "mycase is 1 or 2"
} esac
} ===
} Note that ";|" provides an OR-like separator (as opposed to the AND-like
} ";&" separator)
This analogy doesn't work. Semantically, the test for whether $mycase
matches any one of the labels occurs once at the top of the statement.
Control then jumps into the body as if with a GOTO, and thereafter all
you're able to change with ;& is how early you exit from the body. It
isn't anything like AND / OR.
By comparison, your proposed ;| requires the interpreter to reproduce
the pattern match test at every label, which implies storing the result
of expanding $mycase, etc. Most languages don't allow one to hide quite
that much complexity behind syntactic sugar.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author