Re: redunant match

Matthias Blume <[email protected]> Wed, 6 Jun 2007 07:31:07 -0500
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
Given that the constructors didn't exist, the ML compiler assumes
that you wanted to use these names as ordinary (pattern-) variable
names.  Of course, if Inner is a variable, then it will match
anything, and all subsequent patterns are redundant.

This is a known design shortcoming in SML, where constructor names
an variable names are not lexically distinct.

Matthias

On Jun 6, 2007, at 12:22 AM, brian wrote:

> OK, once again I am stymied by the simplest of sml code
>
> I have a datatype:
>
> datatype ticStyle =  Inner | Outer | Both | None
>
> I test the code on the command line:
>
> datatype ticStyle = Both | Inner | None | Outer
> - val a= Inner;
> val a = Inner : ticStyle
> - case a of Inner => "i" | Outer => "o" | Both => "b" | None => "n";
> val it = "i" : string
> -
>
> In my code I have something that looks like:
>
>    val ytic = case x_tic_style of
>          Inner => "i"
>        | Outer => "o"
>        | Both => "b"
>        | None => "n"
>
> And I stop right there, because I get:
>
> psgraph.sml:83.33-87.48 Error: match redundant
>            Inner => ...
>      -->   Outer => ...
>      -->   Both => ...
>      -->   None => ...
>
> -
>
> What was I doing wrong, easy I wasn't using the structure qualified
> name:
>
>    Module.Inner
>    Module.Outer
>
> etc...
>
> Why didn't I get an error related to the fact the Inner, Outer,
> etc... don't even exist as opposed to the wacky redundant error ?
>
>
>
> Brian
>
>
> ---------------------------------------------------------------------- 
> ---
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Smlnj-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/smlnj-list
>


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/