-
Notifications
You must be signed in to change notification settings - Fork 1
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
Replace built-ins by general overloaded functions #288
Comments
My thought is to have a One There would also be a With this in place, To further simplify things, we can use the One of the nice things about this is that with currying, if you wind up with a On the other hand, Migrated from internal repository. Originally created by @EvanKirshenbaum on Jul 09, 2023 at 11:03 AM PDT. |
This would also make it straightforward to support both default values for function arguments (#160) and the ability to specify an argument as If I ever get the time to add statement-level function definitions (also #160), having multiple function declarations with the same name declared in the same scope could similarly result in a single overloaded function bound to that name. I'll have to think about what it would mean for one function to shadow another. The simplest thing to do would be to have the inner one completely shadow the other. It might be less surprising to have the inner one shadow any external definition that could take its arguments, e.g., in
the inner Another possibility would be to say that all three definitions are there, but the inner one handles
it would be the outer one that was called. Migrated from internal repository. Originally created by @EvanKirshenbaum on Jul 09, 2023 at 11:21 AM PDT. |
It's time to replace another kludge.
Currently, DML has the notion of a
CallableType
, which has aSignature
, and which is implemented by aCallableValue
(which also has aSignature
). This works fine for macros, and also things likeMOTION
,DELTA
, andTWIDDLE
, implemented by instances of subclasses ofCallableType
.Type.as_func_type
, which allows conversion to a supertype that's a subclass ofCallableType
also means that it works for things likeDIR
. This works pretty well for functions that have a single signature.But there are a number of common operations that we need to be overloaded. For example,
transfer in
currently has the following signatures:The forms that return callables are created by currying the ones above them. Note that there are two forms that both take a
LIQUID
and return a callable. In fact, the way things are currently implemented, if you saytransfer in(2 uL)
, what you'll get is a function that returns anep -> ep
, but there's a special kludge that allows bothto work.
The way all this works, is that there's a special (Python) global dictionary,
BuiltIns
that maps names toFunc
objects, which have the ability to register multiple functions and find the tightest match for overloads.The downside to this is that when
transfer in
is seen, the name expression compiler has a special case where it looks inBuiltIns
and returns theFunc
with typeBUILT_IN
. And the function call, injection, andis
expression compilers have special cases to handle seeing them.That's the problem. Solution to follow.
Migrated from internal repository. Originally created by @EvanKirshenbaum on Jul 09, 2023 at 10:13 AM PDT.
The text was updated successfully, but these errors were encountered: