Skip to content
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

Should ren::Float be willing to implicitly (or explicitly) cast from a ren::Integer? #7

Open
hostilefork opened this issue Dec 13, 2014 · 0 comments

Comments

@hostilefork
Copy link
Member

The current static_cast system is based on casting through the hierarchy of wrapper classes in a way that preserves their bits. You can static_cast a ren::String to a ren::Value, then up to a ren::AnyString, and back to ren::String again.

However, in that process the bits didn't change. For instance, in Red, it was the same RedCell the whole time, just being safely cast through the inheritance hierarchy of the C++ classes.

Should steps be taken outside of this? C++ isn't going to have the same behaviors, like statically checking against a dynamic typeset. But it can have some features Red or Rebol doesn't have, like being willing to implicitly cast a float.

However, it is additional complexity to add such a feature...and perhaps it is more likely to confuse users of the binding than to offer real benefit. After seeing a red::Integer implicitly coerce in the binding (which would involve different bits underneath on the source and target), they may wonder why they can't do this:

foo: func [value [float!]] [
    // ...
]

x: 10
foo x
@hostilefork hostilefork changed the title Should red::Float be willing to implicitly (or explicitly) cast from a red::Integer? Should ren::Float be willing to implicitly (or explicitly) cast from a red::Integer? Dec 19, 2014
@hostilefork hostilefork changed the title Should ren::Float be willing to implicitly (or explicitly) cast from a red::Integer? Should ren::Float be willing to implicitly (or explicitly) cast from a ren::Integer? Dec 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant