JoeStrout / miniscript

source code of both C# and C++ implementations of the MiniScript scripting language
MIT License
272 stars 63 forks source link

differences between miniscript and Mini Micro #165

Open badiku opened 1 month ago

badiku commented 1 month ago

hi, how to add prototype to function?

funcRef.a=function()
>>> print "hello"
>>> end function
> (@print)["a"]
Runtime Error: Key Not Found: 'a' not found in map [line 1]
> (@print).a
Runtime Error: Key Not Found: 'a' not found in map [line 1]

but, in Mini Micro, this works:

] funcRef.a=function()
...] print "hello"
...] end function
] (@print)["a"]
hello
] (@print).a
hello

both latest version 1.6.2

and why null +3 is null , 3+null == 3 ?

https://miniscript.org/wiki/Null Numeric arithmetic with null is null When null is involved in any numeric expression, the result is null. For example, null + 42 is null.

Withered-Flower-0422 commented 1 month ago

The first problem is a known bug, see in #70 .

The second question:

  1. String has the highest priority. If an expression has strings, the result is a sting. (null + "1" == "1"; 2 + "3" == "23")
  2. Otherwise, MiniScript tends to convert the data type to the same as what it meets first. (null + 3 == null; 3 + null == 3)
  3. Lists and Maps have their own method of calculation.
juh9870 commented 1 month ago

@Withered-Flower-0422 The first issue has nothing to do with #70. #70 only happens with (@a.b).c, not (@a).b, and even if it did, ["a"] completely avoids it.

The issue looks like c++ version doesn't allow properly lookup on the funcRef objects, or at least doesn't look up funcRef map for them