[bitc-dev] No operator precedence [was: Syntax: procedure call.]
Sandro Magi
naasking at higherlogics.com
Mon Apr 19 13:02:56 PDT 2010
Oops, I mean a "pattern-matching-like form" for conditionals.
Sandro
On 19/04/2010 3:57 PM, Sandro Magi wrote:
> I wasn't suggesting pattern matching, just a pattern matching form for
> conditionals.
>
> Sandro
>
> On 19/04/2010 3:02 PM, Jonathan S. Shapiro wrote:
>> 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
>> <mailto: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 <mailto:bitc-dev at coyotos.org>
>> http://www.coyotos.org/mailman/listinfo/bitc-dev
>>
>>
>>
>>
>> _______________________________________________
>> bitc-dev mailing list
>> bitc-dev at coyotos.org
>> http://www.coyotos.org/mailman/listinfo/bitc-dev
>
>
> _______________________________________________
> bitc-dev mailing list
> bitc-dev at coyotos.org
> http://www.coyotos.org/mailman/listinfo/bitc-dev
More information about the bitc-dev
mailing list