-
Notifications
You must be signed in to change notification settings - Fork 20
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
Allow application in combination with dynamic (?) operator #543
Comments
I wouldn't mind having something like this kicking around, but I'd rather it wasn't in my namespace by default and would require you to open a module first. |
@Rickasaurus Absolutely! Maybe I was not clear in the description, but this is not proposing that Right now the |
@alfonsogarciacaro Is there still any need for this from the Fable side? |
@dsyme The current workaround seems to be working well and I didn't get any feedback from users on this regard for years, so if it's not needed for anything else, we can close the suggestion. Thanks a lot for reviewing! |
I propose we improve dynamic programming with F#. In Fable, we're almost there with the use of three operators:
?
dynamic operator, defined in standard F# but implemented by Fable!!
dynamic casting, defined by Fable and equivalent tounbox<'t>
$
operator to apply arguments directly to anobj
type.With these operators you can do something like this:
However, the
$
operator has problems. Besides not being very nice, the precedence rules don't let you do something likemyObject?foo?bar$(4, 5, 6)
.Fable is solving this at the moment by implementing
?
with the following signature: `obj->string->(obj->obj). This means the user can now do something like this:This is very close to a dynamic experience and makes it very easy to temporarily cancel type checking when the user needs to interact with untyped code. However this hack is still no ideal, there are two main problems.
let x = myObject?foo
, users expectx
to be of typeobj
, notobj->obj
.It would be very useful if the F# compiler allowed directly the application of any number of arguments in combination with the
?
operator without the Fable hack. This would be similar to the currently available combination of?
and assignment.Probably a similar syntax should be used, but I'm not sure how it should be:
?
on their own, so the risk is mitigated for standard codeAffadavit (must be submitted)
Please tick all that apply:
The text was updated successfully, but these errors were encountered: