using Nemerle.Text;
def GetLanguage(path)
{
regexp match (path.ToLower())
{
| @"file-(?<language>..)\.txt" => language
| _ => "none"
}
}
System.Console.WriteLine(GetLanguage("file-fr.txt"));
but the following does not:
using Nemerle.Text;
def GetLanguage(paths)
{
mutable result;
foreach (path in paths)
{
result =
regexp match (path.ToLower())
{
| @"file-(?<language>..)\.txt" => language
| _ => "none"
}
}
result;
}
System.Console.WriteLine(GetLanguage([ "file-fr.txt" ]));
test.n|9 col 4| 13:5: error: unbound type `matchobj.Groups["language"]'
test.n|9 col 4| 13:5: error: unbound name
`matchobj.Groups["language"].ToString'
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
12-17-08 17:13 Don Reba New Issue
======================================================================
----------------------------------------------------------------------
NN - 12-18-08 11:06
----------------------------------------------------------------------
I have the same problem while implementing regexp foreach:
http://rsdn.ru/forum/message/2943448.flat.aspx#2943448
I get the similar errors:
Error: unbound type 'matchobj.Groups["_N_4560"]'
Error: unbound name 'matchobj.Groups["_N_4560"].Success'
Error: unbound type 'matchobj.Groups["x"]'
Error: unbound name 'matchobj.Groups["x"].ToString'
It works for
def s = regexp foreach(a in ["a", "b"])
{
| "a" => "a"
| "b" => "b"
| _ => "c"
}
But not for
mutable s = "";
regexp foreach(a in ["a", "b"])
{
| "a" => s = "a"
| "b" => s = "b"
| _ => s = "c"
}
Issue History
Date Modified Username Field Change
======================================================================
12-17-08 17:13 Don Reba New Issue
12-17-08 17:13 Don Reba Issue Monitored: Don Reba
12-18-08 11:06 NN Note Added: 0002154
======================================================================
----------------------------------------------------------------------
NN - 12-18-08 11:08
----------------------------------------------------------------------
Mistake:
I meant s = x instead s = "a"
Issue History
Date Modified Username Field Change
======================================================================
12-17-08 17:13 Don Reba New Issue
12-17-08 17:13 Don Reba Issue Monitored: Don Reba
12-18-08 11:06 NN Note Added: 0002154
12-18-08 11:08 NN Note Added: 0002155
======================================================================