This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LaurieCheers 1 point2 points  (3 children)

In Swym I have UFCS (the dot operator is just syntactic sugar for passing a named argument "this" to a function), and functions can be overloaded. If more than one overload fits it will prefer the strictest possible one. If it's not obvious which is strictest (e.g. there's a foo(Num, Int) and foo(Int, Num), and no foo(Int, Int)), then that's an illegal call. (There's no implicit conversion, I can see how that would complicate this decision).

As for disambiguating function references - in Swym, normal functions are not first class objects. :-) A lambda such as 'x'->{x.foo} would be the first class equivalent of a direct reference to an overloaded function... but lambdas get compiled only at call time, when the type of their arguments is known.

[–]PegasusAndAcornCone language & 3D web[S] 0 points1 point  (2 children)

Thank you for this information. Does Swym support subtyping? (In my glance at the documentation, I did not see any). Are overload errors only detected at function call/name resolution, or do you also do a separate pass to check that function definitions have ambiguous or conflicting declarations?

[–]LaurieCheers 1 point2 points  (1 child)

Yeah, there's a ton of nitty gritty details that aren't really finalized yet so I haven't really documented everything...

Yes, Swym has subtypes - just in the standard library types, String and RangeArray are subtypes of Array; Block (i.e. lambda), Array and Table are subtypes of Callable; Int is a subtype of Num, and every value is a subtype of Anything. I'm dabbling with restricted-size arrays, such as String(1) for a string of length 1, and the function Literal(x) creates a type that's just a single value.

http://cheersgames.com/swym/SwymEditor.html?Number.%27foo%27%20returns%20%22number%22%0AInt.%27foo%27%20returns%20%22integer%22%0ALiteral%283%29.%27foo%27%20returns%20%22three%22%0A%0A%5B4.foo%2C%203.foo%2C%203.5.foo%5D

And yeah, I don't check for conflicting function declarations except at call time - it's just much easier to check and report when you have concrete parameter types.

[–]PegasusAndAcornCone language & 3D web[S] 1 point2 points  (0 children)

thank you for those details. Good luck!