Comments on: Datatype conversions that make sense
With so many built-in datatypes, there are many choices for what types of native conversions to support and which ones are meaningless.
Last week I wrote a line of code that did this:
word: make word! state
where state was a logic value, either TRUE or FALSE.
Of course, it threw an error, and I used a different method. Not a big deal really, but it seemed to me that the code should have been allowed.
So, yesterday, I added it... a single line change and it now works just fine.
But, here's the question: when it comes to such conversions, which do we want to support natively? Some conversions make a lot of sense, others are useless, and we shouldn't bother with them.
Or reworded as a question to you as developers: what conversions are we lacking that are a problem for you?
For example, a couple weeks ago I wrote:
obj: make object! map-val
Where map-val was of type map! The conversion is not supported, so I made it:
obj: make object! to-block map-val
but, that creates an extra block and performs a needless reduction (evaluation) of the block. So, here again, the direct conversion seems useful.
Personally, I think we need to make a list of "desired conversions" that we can prioritize, then add them, up to a limit.
There should definitely be a conversion from map! to object!, and that makes more sense than converting it to block at all. Semantically there is little difference between map! and object! right now.|
I don't know which types are supposed to be convertible, but I do know that Docbase will need a nice big table of those conversion possibilities. It's ok to experiment in the console to get a specific conversion working, but sometimes, a table would make it easier to see if something obvious is missing.
The table could be autogenerated. OK, back to topic. :-)
Would have helped me recently in fact. I thought [to time! none] would throw an error, but it produces 0:00.|
Ok, thanks for the input.
Also, DocBase does have some nice big tables... thanks to a script by Gregg. Of course, we (main rebolers) need to look over the results and make some decisions.
This is also typically a 3.1 improvement?|
Post a Comment:
You can post a comment here. Keep it on-topic.