-
Notifications
You must be signed in to change notification settings - Fork 15
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
Implementing explicit casting #113
Comments
That maybe "5" should not be an uint of size 3: The size could be related to its use. |
The "5" is just an example, it can be an general expression. And why don't you like this explicit casting ? What is the problem with it ? |
One question (which seems quite important): Do you plan to implement it yourself ? |
There is nothing on the standard about explicit casting. Yes it is ugly but it follows the typing of CAL and you can specify the size of it. This is future work, and we are planning to do quite a lot of stuff in the beginning of the next year(thesis defence in December ). So yes I am planning to implement that myself. |
@endrix There are explicit castings from int to float and vice versa in the standard. |
@mraulet, great for float to int. But what happens to int to int with different size and casting of bool to into and int to bool. Now it depends what we want to do with the language and I think there is an interest on explicit casting in certain situations. Like for example to not use an if statement for converting a bool to int. |
I'm agree with bool/int conversion... But, resizing an integer can always be done using a specific statement: It is not so painful to do... |
After all, even bool/int conversion is not really useful: |
It is time to add explicit casting.
Having this as an example what is the value of t ?
For Orcc "5" is an uint of size 3 and "not" of 5, ~5 = 2.
So now if i want a not on 32 bits I need to :
Which is kind of limiting.
And now what about the programmer ! What a C programmer going to CAL think of
As a solution to this "casting" I propose to add to the frontend the possibility to cast expressions.
An example of casting can be written like that :
can lead to t to have a value of 10.
Also in the IR we have already the cast instruction, we need to change the frontend and we can create rules on casting different types like e.g. boolean to integers.
What do you think ?
The text was updated successfully, but these errors were encountered: