wenyan icon indicating copy to clipboard operation
wenyan copied to clipboard

Idea for non-currying function

Open Meowcolm024 opened this issue 5 years ago • 4 comments

I don't know whether it is duplicated. Is it possible to add a new syntax for calling non-currying functions? (Like some built-in functions or some in other packages. It could be like:

以 甲,乙,丙 入 「某物」。

Equal to:

something(a, b, c);

Meowcolm024 avatar Jan 07 '20 14:01 Meowcolm024

Hi @Meowcolm024 , currying happens during function definition, adding a new calling syntax can not change the curried nature of the functions already defined. Technically we can un-curry the function on the spot, implemented like so

;(function(a,b,c){return 某術(a)(b)(c)})(甲,乙,丙)

I think currying has some good properties and we should generally encourage it, but you also made a good point about calling foreign functions. Currently a simple solution would be

施「(a=>b=>Math.max(a,b))」於「甲」於「乙」。

But I'll also consider adding the functionality into stdlib, e.g. usable like so:

施「盡施」於「Math.max」。於二。於「甲」於「乙」

Thanks for bringing this up!

LingDong- avatar Jan 07 '20 15:01 LingDong-

施「盡施」於「Math.max」。於二。於「甲」於「乙」

A good idea. This way need not new syntax. The only disadvantage is that it's not succinct and efficient enough.

If you consider to add new syntax, how about the following or similiar?

盡施「Math.max」於「甲」於「乙」

And, some foreign functions receive uncertain number of parameters. For example, you can use Math.max like Math.max(a, b, c, d, e) or Math.max(...numberArray)

cuixiping avatar Jan 08 '20 01:01 cuixiping

I enjoy the auto-currying function is one of the interesting design, the chained “于” sound well respect to traditional Chinese. So what is the difference for normal user, since the underlying currying is automatically.

lymslive avatar Jan 08 '20 09:01 lymslive

@lymslive Well, I suppose that the point is not for user defined functions (or calling them), but rather about foreign functions, as most of them are not curried, so you may not be able to run these function without certain modifications.

Meowcolm024 avatar Jan 08 '20 09:01 Meowcolm024