[bitc-dev] No operator precedence [was: Syntax: procedure call.]

Jonathan S. Shapiro shap at eros-os.org
Mon Apr 19 12:02:06 PDT 2010


Given where I think we're going to end up in BitC with inheritance, pattern
matching becomes tricky. It's also surprisingly difficult to compile/check.
The number of research papers on how to do that is a strong argument for why
it might not be a good idea.

shap

On Mon, Apr 19, 2010 at 11:37 AM, Sandro Magi <naasking at higherlogics.com>wrote:

> On 11/04/2010 6:30 PM, Jonathan S. Shapiro wrote:
> > // curried:
> > def fact x =
> >   if (x < 0) then - (fact (-x))
> >   else if (x == 0) then 1
> >   else x * fact (x - 1)
> >
> > // non-curried:
> > def fact x =
> >   if (x < 0) then - fact(-x)
> >   else if (x == 0) then 1
> >   else x * fact(x - 1)
>
> Just a stylistic suggestion: I now rather dislike the if-else form, and
> prefer pattern-matching like forms.
>
> Consequently, I tend to now use ternary operators in my C and C# code
> which results in such a clearer form. The above function would look
> something like:
>
> def fact x =
>  (x == 0) ? 1:
>  (x < 0)  ? - fact(-x):
>             x * fact(x - 1);
>
> I'm not suggesting ternary operators or pattern matching here, just
> supporting the idea of a syntax for conditionals where nested/chained
> conditionals have a more readable structure.
>
> Sandro
>
> _______________________________________________
> bitc-dev mailing list
> bitc-dev at coyotos.org
> http://www.coyotos.org/mailman/listinfo/bitc-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.coyotos.org/pipermail/bitc-dev/attachments/20100419/c226d9b6/attachment.html 


More information about the bitc-dev mailing list