Re:Show HN: KatLang – Language for Calculations
by throwaway4good on Thursday December 02, 2021 @06:58AM
(#29415047)
It creates the situation where these two functions appear to be identical but they are not:
It is an interesting subject, and in general you would want to balance usability, people's expectations, and succinctness.
[ Parent
| on HN ]
Re:Show HN: KatLang – Language for Calculations
by rabarbers on Thursday December 02, 2021 @07:04AM
(#29415090)
It is not the same.
A1 = x * y + x
A2 = y * x + x
A1(1, 2), A2(1, 2)
returns results 3, 4
If You want to change parameter order, You can use Grace~ operator like this: A1 = x~ * y + x
it moves parameter x one position towards the end of the parameters list.Sorry, I do not know how to post code snippets in HN properly.
Re:Show HN: KatLang – Language for Calculations
by geocar on Thursday December 02, 2021 @11:17AM
(#29418080)
I think they meant:
A1 = x * y + x
A2 = y * x + y
Re:Show HN: KatLang – Language for Calculations
by rabarbers on Thursday December 02, 2021 @12:26PM
(#29419264)
A1 in Javascript pseudocode would be:
function A1(x, y) {return x*y + x; }
But A2 would be: function A2(y, x) {return y*x + y; }
If you do not like the default order of implicit parameters, you can always use Grace~ operator to move x or y. Prefix form moves the parameter one position towards the beginning of the parameters list, postfix form moves one position towards the end of the parameters list: A1 = y~ * x + y
or A1 = y * ~x + y
or
[Edit] A1 = y * x + y~
In the last example take into consideration, that without Grace~ operator y is the first parameter, so, you need to move it one position towards the end of the parameters list - therefore use postfix form of Grace~ operator.
Re:Show HN: KatLang – Language for Calculations
by throwaway4good on Thursday December 02, 2021 @07:14AM
(#29415164)
Indent with 3 spaces or more.
Re:Show HN: KatLang – Language for Calculations
by chrismorgan on Thursday December 02, 2021 @08:03AM
(#29415569)
(Two, actually.)