Nov-21-2017, 05:03 AM
today i had a "thinking-glitch" writing some code and got the error message
there was a language i programmed in, in the past, that support this, and it was more the just a function call in the LHS (for example to return a value used as a subscript value). it was a function call as the actual l-value. the language had a special function call interface where the function, when called this way, could see that it was called this way, an got the value being assigned to it. it was a language that passed arguments by reference, so the called function could assign to its arguments. so they did stuff like sin(x) = y in place of x = cosin(y). the big debate in that language was "x*x = y" to fo "x = sqrt(y)" though it did no that. the sin() was just implement to know what to do.
i'd like to see part of this, just the assignment to function call, implemented in Python. when such an assignment was done, if the function definition did not support this, it would be an exception. if it did support it, the function would be called, and passed the assigned value. the syntax could be like:
SyntaxError: can't assign to function call
. i had coded a function call where i should have coded a dictionary reference. so the error message is extly correct. but, it got me to thinking.there was a language i programmed in, in the past, that support this, and it was more the just a function call in the LHS (for example to return a value used as a subscript value). it was a function call as the actual l-value. the language had a special function call interface where the function, when called this way, could see that it was called this way, an got the value being assigned to it. it was a language that passed arguments by reference, so the called function could assign to its arguments. so they did stuff like sin(x) = y in place of x = cosin(y). the big debate in that language was "x*x = y" to fo "x = sqrt(y)" though it did no that. the sin() was just implement to know what to do.
i'd like to see part of this, just the assignment to function call, implemented in Python. when such an assignment was done, if the function definition did not support this, it would be an exception. if it did support it, the function would be called, and passed the assigned value. the syntax could be like:
def putstring(self,x) assigned s: self.array[x] = s returnthis could be especially useful with classes.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.