On 8/10/19 2:17 AM, Waldek Hebisch wrote:
> oldk1331 wrote::
>>
>> I don't like the grammar that uses
>>
>>     "func"/list1
>>
>> to do
>>
>>     reduce(func, list1)
>>
>>
>> First, this is a strange grammar.
>>
>> Also I don't like to have special grammar to do things can
>> be done by normal grammar.
> 
> I am affraid the classic answer is appropriate here
> "it is a feature, not a bug".
> 
> Expanding on it a bit: it is usual that syntactic choices
> cause some disagreement.  From my point of view this is
> useful shortcut for frequently occuring operation.

We already have an useful shortcut for this frequently
occurring pattern (the reduce pattern): function "reduce".

> It does not significantly increase complexity of the
> parser and beside parser we need smal amount of extra
> code.  So from implementation point of view it is
> cheap feature.  I so no reason to remove it.

I think it's bad design to have special grammar do things
that normal function can do.

> @Ralf: this construct kowns about identity for several
> popular operations, so in such case works also for empty
> lists.  Of course, it would be nicer to do this in more
> systematic way.

It's also a bad design to hard-code extra knowledge into
compiler.

>> This patch replaces '"append"/' with normal function call
>> 'concat : List % -> %', it's simpler and faster.
>>
> 
> Well, simpler is debatable.  Faster is useful if speed
> matters.

For common usage, we already have "gcd : List(%) -> %"
defined as "gcd(l : List %) == reduce(gcd, l, 0, 1)".
now comparing the following:

"gcd"/[f(i) for i in l]
gcd [f(i) for i in l]

At least it is 3 characters simpler and less confusing.

>>
>> If you agree, I plan to replace other usage of '"func"/' by
>> normal function calls.
>>
>> grep '"[a-zA-Z]*" */' *spad   shows 135 usage of such grammar,
>> only uses function max/min/setUnion/and/or/gcd/lcm.
> 
> Well, as I wrote I think that "op"/... is a useful feature.
> And it is useful to have some test cases for features.
> So I would like to keep some (preferaby most) of uses of
> this construct.
> 

I propose I only do the cleanup for "concat", "gcd" , "lcm"
for now, because they already have signature "List % -> %".

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/59772f28-32e6-2452-4dea-525838e77069%40gmail.com.

Reply via email to