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

Is it possible to make dascript auto promote / convert types #95

Closed
taylorius opened this issue Jan 29, 2021 · 2 comments
Closed

Is it possible to make dascript auto promote / convert types #95

taylorius opened this issue Jan 29, 2021 · 2 comments

Comments

@taylorius
Copy link

Hi again,

I have a number of c++ functions which take a number of parameters, some of which are floats, and some ints. I've noticed that dascript is strict with making sure types agree exactly, which of course is as it should be.

However, I would like a way to allow some automatic type conversions (int to float, and vice versa) when interfacing with a c++ function.

For example, if I have a c++ function registered in dascript :

float sum(float a, float v)
{
return a+b;
}

And I call it from dascript like this:
var dist:int
dist=4
tot=sum(3.2,dist)

Is it possible to configure dascript to not complain during compilation, but to cast the variable dist to a float, and pass it to the c++ function?

I could define and register functions with every possible combination of variable types - but the combinatorics could make that difficult, so I was wondering if there was a more elegant way of achieving this.

Thanks a lot for any advice you might have.

Matt

@borisbat
Copy link
Collaborator

borisbat commented Feb 2, 2021

Currently no and likely will not happen. There is cost or functionality associated with conversions, and we want those to be explicit.

@taylorius
Copy link
Author

Understood. Thanks for the answer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants