On 8/15/19 5:03 AM, oldk1331 wrote: > 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.
I agree with Qian on this. Suppose in a domain I have a domain that exports +: (%, %) -> % and I define a function /: ((%, %) -> %, List %) -> % and then write _+ / [a, b, c] for a, b, c of type %. Will the compiler use its internal knowledge about the "x" / list special grammar or will it use my definition of / ? > 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. I support the call without "/". > I propose I only do the cleanup for "concat", "gcd" , "lcm" > for now, because they already have signature "List % -> %". This would also be a compromise for now. Eventually, I also think, we should remove this special grammar. Ralf -- 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/7c3533d0-c479-b2f5-5cfb-f3f97cc2f7ff%40hemmecke.org.
