NSExpression's expressionWithFormat

UPDATE: This handler value should be doubleValue() so I have correct that.

set theValue to my expressionWithFormat:"add:to:(10,50)"
on expressionWithFormat:theExpression
	return ((current application's NSExpression's expressionWithFormat:theExpression)'s expressionValueWithObject:(missing value) context:(missing value))'s doubleValue()
end expressionWithFormat:

To get the expression representation you should not ask for its value:


use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set theExpession to current application's NSExpression's expressionWithFormat:"add:to:(10,50)"
log (theExpession)

--> RESULT: "(NSFunctionExpression) 10 + 50"

Its was the value I was interesting in and on my machine I got the right result in log but
not as result. That why I created this topic in the first place. The solution was to restart my computer and everything is correct.

I guess Apple Events or communication to it could hang. The strange thing was that the log worked.
It have never happen to me before.