Is there a way to replace a built-in function?

Graham Samuel livfoss at mac.com
Mon Jan 5 07:53:42 EST 2015


On the face of it, it’s impossible to replace a built-in function in LC. For example, take the function ln(x) - that’s natural logarithm. I’d like to redefine ln(x), but I can’t because the compiler won’t let me use a reserved word in a function definition.

I wonder if anyone can suggest a trick to allow a redefinition like this. If not, then roll on Widgets.

Graham

PS In case you want to know why I want to redefine this function, it’s for the following reason.  Generally, mathematicians say that ln(0) is undefined, whereas the limit as x approaches zero is minus infinity. This is a bit subtle, and LiveCode takes no real notice of this, so that in LC, ln(0) yields “-inf”. Despite a contrary definition in the LC dictionary, this text is then regarded as a number, which can cause confusion, at least to me. So my new ln(x) would yield undefined for ln(0) and would use a symbol for minus infinity which LC would not then recognise as a number.



More information about the use-livecode mailing list