Re: C-like Structures
- Posted by mattlewis (admin) Jul 14, 2011
- 2808 views
The access method here appears to rely on knowing the type, which is often not the case (such as when one gets stored in a sequence).
There are times where we only want the aliases for the members. I agree with that.
I don't understand what you're saying here. I was pointing out the difference between:
my_point.point.x -- works with any atom that holds a valid pointer -- vs my_point.x -- ONLY works when we absolutely KNOW that my_point is of euphoria type point
I guess the type checking could flag when you try to assign something that doesn't fit into the field, or maybe a signed vs unsigned problem. Though I don't think we'd need to stuff that into a type, since it's really different than a UDT, and has plenty of type information automatically.
Yes, it is different but it seems to go against the spirit of the work to abandon it if we cannot have both at the same time.
I disagree. Remember, this is a replacement for peek/poke, ultimately. We allow overflow in pokes, so I think it would make sense to do it here.
And really, there's no point in validating in the way that you've set up here, because by definition, the bytes in RAM can only store what they can store. What would be an invalid value for an int?
I think if type-checking is a good idea for EUPHORIA types, it is a good idea for C types as well. An object can contain most numbers you will think of but not all of these numbers can be correct in all contexts. For example, a point in a display must have positive numbers and must be limited to the size of the display it belongs to.
That's completely false. It's perfectly permissible to have negative points. But anyways, if you wanted only non-negative numbers, use an unsigned type. I suppose it's true, however, that some libraries could apply their own bounds for certain members.
I'll concede that some automatic type checking for memstruct assignments might be worthwhile.
Once we get all of these ideas worked out this would be nice to do in sequences as well. Instead of always defining constants for members of a sequence.
Yes, that's been on most people's wish lists, I think, for some time.
Matt