[nem-bug] [Nemerle 0000758]: shortcut for match syntax
feedback at nemerle.org
feedback at nemerle.org
Mon Sep 18 20:10:00 CEST 2006
The following issue has been SUBMITTED.
======================================================================
<http://nemerle.org/bugs/view.php?id=758>
======================================================================
Reported By: aleksey
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 758
Category: Language Feature
Reproducibility: N/A
Severity: feature
Priority: normal
Status: new
======================================================================
Date Submitted: 09-18-2006 20:10 CEST
Last Modified: 09-18-2006 20:10 CEST
======================================================================
Summary: shortcut for match syntax
Description:
Recent postings in nemerle.devel-en("?? operator" and "match / default
case") reminded me of my old idea. I'm not sure whether it's crazy or
worthwhile, it's up to you.
What I propose is a ?| operator(I couldn't come up with better "name"). It
can be used a complete replacement for "match", but it also has a special
support for option.None and null.
Some examples:
def test = Some("test");
def value = test ?| None => null;
def value = test ?| None => return; // this is evil of course, but it's
just an example
def value = test ?| Some(value) => value ?| _ => null;
assert(value == "test");
value ?| "test" => WriteLine("value == test") ?| null => WriteLine("value
==
null");
// it also can be used instead of (b ?? c)
// b ?| null => c
WriteLine($"$(value ?| null => \"null\")");
// otherwise from special treatment for null and None
// it has little other differences from match
// unlike in match branch several expressions should be placed in block
lst ?| [x, y] => { WriteLine("hello!"); x+y }
?| [x] => x
?| _ => 0
Sometimes it can make code a bit more cryptic, but so do ??, :> and many
other operators.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
09-18-06 20:10 aleksey New Issue
======================================================================
More information about the bugs
mailing list