[nem-en] Try unless syntax, macros

Kamil Skalski nazgul at nemerle.org
Thu Sep 9 21:29:15 CEST 2004


>Well, the different keywords were just because i implemented it as a macro,
and the >with the current system it wasn't possible to make it use the
existing keywords, so i >just used the first word i could think of that
meant roughly the same thing. As for the

Yes, with new syntax extender more things will be possible to do.

>catch being before the do, i think that's probably an advantage, overall,
at least in the >common case (catching a single exception, then doing lots
with the object if the

I agree. Handlers are in most cases very short.

>allocation succeeded). I think i'd prefer try(...) unless {...} do {...} ,
>though, since at least to me, it expresses the intent better (try this,
then unless this >happens, do this). Having the exception handling bit be a
proper block is definitely a >good idea, since it would allow you do filter
and do different things on different types

It is not always clear, what is the semantics of `unless { } do {  }'. This
could be understood by somebody like unless (..) {   }, which means unless
some condition is true do this...  `catch' keyword is much more unambiguous
in its meaning in presence of `do' block. There is one more problematic
thing about this construct. We want body of `try (...)' to be visible in
handler and `do' part, which is quite different from standard
`try {..} catch {.. } finally {..}' construct. And here using `unless' would
be helpful to visually distinguish them.

>of exception, which could be extremely useful in some circumstances. I
unfortunately >couldn't work out how to do that, though - quoting
> <[ $ex : $type => $handler ]>
Yes, I wrote a short summary in MacroTips page. Note that soon quotations
will be reworked somewhat, allowing more uniform and consistent usage.Kamil
Skalski





More information about the devel-en mailing list