Re: "OF" in types, yet again...
- Posted by Patrick Barnes <mrtrick at gmail.com> Jul 04, 2004
- 489 views
> posted by: Robert Craig <rds at RapidEuphoria.com> > Thanks, I downloaded the zip and took a quick look at it. > I have no technical problems with implementing > something like this. As I said, I studied this in great detail > a few years ago. It's a logical and elegant extension to > the language. I would not restrict it to one-level of slice or > force the new syntax to appear only within a type declaration. > e.g. I would allow an infinite number of levels: > sequence of sequence of ... <type> x > > Of course people will naturally demand a way to declare structures > and add them to the type system. e.g. sequence of mystruct x Which is not mutually exclusive with the "of" system. > I don't need a benchmark to show me that type checking one (subscript) > or a few (slice) elements will be much faster than checking > the whole sequence. > > The only thing holding me back is that I doubt many people > would use this, and those that would use it would not benefit > greatly from it. I can't see many people bothering to say: > > sequence of sequence of integer s > > when they can just say > > sequence s > > I've found that most people are more interested in how few keystrokes > they can type to get the job done, than they are with adding > extra type-checking, especially with all the run-time checking > that Euphoria already has. I can type ~ 50wpm. I'm more interested in knowing where a bug in my program occured, something that is a *lot* easier to do with speedy yet comprehensive type definition. > Beginners would have to read a big new section of the manual > describing all these wonderful types that they can create. > They would falsely conclude that this was an essential > part of the language, without which you can't do anything, > just like C++ or most other statically-typed languages. I think not... Even using the fancy "of" type system, the benchmark is much faster with no type checking whatsoever. I don't think that this would be used (or would simply be turned off) for production code. The key is, that this is a wonderful testing tool. Put this in the testing/debugging section, and it would not be seen as such an essential thing. > In Euphoria, types are for documentation and debugging. Period. > They are not used to construct data structures, like in most > other languages. Thus they are not central to the language, > like they are in most other languages. I wouldn't want to > add a lot of fancy extensions to something that isn't very important. "not very important".... Your super-duper flexible sequences *are* cool, and one can do pretty much anything with them. However, in all non-trivial programs, there are one or two (or more) *large* variables that have a structure very rigidly defined by all the routines that use them. Sometimes we want flexibility, sometimes we want to enforce structure on our own code, so that if it misbehaves and changes something, we'll know about it right away. It is significant. -- MrTrick