-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
functions accepting dynamically typed values #600
Comments
I think the only use for untyped functions is to use them inside the |
This one is implemented. Was rather trivial. |
Well, if you wanted to have a function you call from methods of several different classes, that all have |
There's no need to say
They all have types. |
what if it's a function you're planing to pass to a js object? it doesn't need to be typed and could in fact become unusable outside by adding these restraints. I think it's valid to define dynamic parameters. |
You'd just say |
@RossTate Ross this is something we have been discussing, but right now we do not consider a "dynamic object" to be an |
On the contrary, in the JavaScript environment, objects really don't have types! JavaScript is absolutely not Smalltalk/Python/Ruby where things don't have static types but they do have a type you can discover at runtime. In JavaScript they really don't have types. |
If so, then Ceylon is gonna have major problems cleanly interacting with backends. This is where your problem with As for JavaScript objects not having types, all values have types. These types may not look like what you're used to, but they have types. So, as I say in #604, you could just say that objects with no type tag then have type Lastly, and again, |
I strongly disagree. I don't think we have any insurmountable problem here.
We could do that, and we might eventually wind up doing that, but for now I honestly just don't see enough benefit to doing it.
Sure, but it needs to mean something with semantics sufficiently compatible with JavaScript that we can take a piece of code using |
Sounds good. The one immediate action item I would say, then, is to make |
So the new
dynamic
blocks let me mix typed and untyped expressions together and can even contain declarations whose type is "dynamic". The way this works is by distinguishing between expressions and declarations which have a type, and expressions and declarations which don't. There's noDynamic
type breaking the whole type system with special-case assignment rules, rather we just accept that we don't know the type, and, because we're in adynamic
block, we suppress the usual errors that would result from that.For example:
Since
foo
andbar
have no type,x
andf()
also don't have types. But the syntax of the language gives us no way to do the equivalent thing with a function parameter. So I think we should support the following syntax, only inside adynamic
block:But this does raise the question of whether we should allow toplevel
dynamic
blocks, in order to have untyped toplevel declarations.The text was updated successfully, but these errors were encountered: