We don't currently have a way to plug into pattern expressions, do we? I 
was toying with the idea of having a simpler interface to the tre 
package, and I was thinking it'd be nice if we could do something like:

match "hello" with
| "hi" => expr1
| regex2 => expr2
| regex3 => expr3
| regex4 as m:regex_match => expr4
| regex5 as s:list[string] => expr5
| regex6 => expr6
| "ho" => expr7
| _ => expr8
endmatch

where the ?m is some way to extract out the regular expression match 
data. How possible would it be to do this? One way I thought it could be 
done is to desugar into this:

// some more magic functions
fun __match_exists__ (x:regex, y:string):bool              = ...;
fun __match__        (x:regex, y:string):opt[regex_match]  = ...;
fun __match__        (x:regex, y:string):opt[list[string]] = ...;

val x = "hello"
match x with
| "hi" => expr1
| _ =>
  if   __match_exists__(regex2, x) then expr2
  elif __match_exists__(regex3, x) then expr3
  else
    match (__match__ of regex_match)(regex4, x) with
    | Some ?x => expr4
    | None =>
      match (__match__ of list[string])(regex5, x) with
      | Some ?x => expr5
      | None =>
         if __match_exists__(regex6, x) then expr6
         else
           match x with
           | "ho" => expr7
           | _ => expr8
      endmatch
    endmatch
endmatch

How doable would this be?

-e


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to