1. Discussion concerning [POLL] Sequences of types
- Posted by Juergen Luethje <j.lue at ?m?.de> Aug 24, 2007
- 733 views
To all people who voted 3. UNRESTRICTED: Are you aware that this is a good source for causing nightmares (as has been discussed previously)? Regards, Juergen
2. Re: Discussion concerning [POLL] Sequences of types
- Posted by Derek Parnell <ddparnell at bigp?nd.?om> Aug 24, 2007
- 661 views
Juergen Luethje wrote: > > To all people who voted 3. UNRESTRICTED: > > Are you aware that this is a good source for causing nightmares > (as has been discussed previously)? I've been busy so I might have missed that discussion. I can't see why it would be any more a problem being unrestricted than being restricted to user-defined-types. integer list X -- only integers can be placed in this. where is the problem? type mt (integer list A) return 1 end type mt X -- only integers can be placed in this. Why is there a difference? -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
3. Re: Discussion concerning [POLL] Sequences of types
- Posted by Juergen Luethje <j.lue at ?mx.?e> Aug 24, 2007
- 661 views
Derek Parnell wrote: > Juergen Luethje wrote: > > > > To all people who voted 3. UNRESTRICTED: > > > > Are you aware that this is a good source for causing nightmares > > (as has been discussed previously)? > > I've been busy so I might have missed that discussion. I see now that this is actually a big problem. So I strongly suggest that everyone who makes a poll, not only asks "Would you prefer A or B?", but also SUMMARIZES THE PROS AND CONS OF THE OPTIONS, according to the previous discussion. > I can't see why it would be any more a problem being unrestricted than being > restricted to user-defined-types. > > integer list X -- only integers can be placed in this. > > where is the problem? > > type mt (integer list A) > return 1 > end type > mt X -- only integers can be placed in this. > > Why is there a difference? Say we have something like names = {"Tom", "Mary", "Bob"} If the new syntax is not restricted, then at least each of the following would be syntactically correct: object names sequence names sequence of sequence names sequence of sequence of object names sequence of sequence of atom names sequence of sequence of integer names and maybe even object of sequence names object of sequence of object names object of sequence of atom names object of sequence of integer names or sequence of object names sequence of object of object names sequence of object of atom names sequence of object of integer names or object of object names object of object of object names object of object of atom names object of object of integer names ( Maybe I forgot a possibility. ) This is very confusing, especially for beginners, and has IMHO nothing got to do with the spirit of Euphoria. That's why Pete Lomax suggested to restrict the new syntax to the definition of types. Then w'd have to create a user-defined type say "word_list", and in our programs we just say: word_list names I'm strongly against the introduction of the new type syntax without this restriction. Regards, Juergen
4. Re: Discussion concerning [POLL] Sequences of types
- Posted by Derek Parnell <ddparnell at b?gpon?.com> Aug 24, 2007
- 665 views
Juergen Luethje wrote: > Say we have something like > names = {"Tom", "Mary", "Bob"} > > If the new syntax is not restricted, then at least each of the following > would be syntactically correct: > object names > sequence names > sequence of sequence names > sequence of sequence of object names > sequence of sequence of atom names > sequence of sequence of integer names Yes, they are all syntactically correct, but each has a different semantics. object names -- Can be assigned with anything. sequence names -- Can only be assigned with a sequence. sequence of sequence names -- Can only contain sequences. sequence of sequence of object names -- same as above. sequence of sequence of atom names -- Can only contain sequences, which -- can only contain atoms sequence of sequence of integer names -- Can only contain sequences, which -- can only contain integers If this is too much for some people to grok then maybe a simplified 'type' alias might be useful. type word_list (sequence of sequence of integer) end type > and maybe even > object of sequence names > object of sequence of object names > object of sequence of atom names > object of sequence of integer names Well, the above would not be valid as they don't start with "sequence". > or > sequence of object names > sequence of object of object names > sequence of object of atom names > sequence of object of integer names However, 'sequence' by itself is already an abbreviation for 'sequence of objects'. > This is very confusing, especially for beginners, and has IMHO nothing > got to do with the spirit of Euphoria. If its the wordiness that worries you then we can solve that with an alias mechanism. And exactly what is "the spirit of Euphoria"? > That's why Pete Lomax suggested to restrict the new syntax to the > definition of types. Then w'd have to create a user-defined type say > "word_list", and in our programs we just say: > word_list names Like the simplified alias syntax I suggested above? > I'm strongly against the introduction of the new type syntax without > this restriction. I don't really think that this concept, which is used in other languages, is all that baffling to newbies and oldbies alike. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
5. Re: Discussion concerning [POLL] Sequences of types
- Posted by c.k.lester <euphoric at c?le?ter.com> Aug 24, 2007
- 664 views
Juergen Luethje wrote: > > Say we have something like > names = {"Tom", "Mary", "Bob"} > > If the new syntax is not restricted, then at least each of the following > would be syntactically correct: > object names > sequence names > sequence of sequence names > sequence of sequence of object names > sequence of sequence of atom names > sequence of sequence of integer names > > and maybe even > object of sequence names > object of sequence of object names > object of sequence of atom names > object of sequence of integer names > > or > sequence of object names > sequence of object of object names > sequence of object of atom names > sequence of object of integer names > > or > object of object names > object of object of object names > object of object of atom names > object of object of integer names That's really horrendous. LOL! :D > I'm strongly against the introduction of the new type syntax without > this restriction. I strongly agree with you.
6. Re: Discussion concerning [POLL] Sequences of types
- Posted by c.k.lester <euphoric at cklester.?o?> Aug 24, 2007
- 675 views
Derek Parnell wrote: > > If its the wordiness that worries you then we can solve that with an alias > mechanism. > And exactly what is "the spirit of Euphoria"? Maybe you can find it here: http://images.google.com/images?source=ig&hl=en&q=spirit+of+euphoria&um=1&sa=N&tab=wi > I don't really think that this concept, which is used in other languages, is > all that baffling to newbies and oldbies alike. Well, since you put it that way...
7. Re: Discussion concerning [POLL] Sequences of types
- Posted by Matt Lewis <matthewwalkerlewis at gm?il.?om> Aug 24, 2007
- 685 views
Juergen Luethje wrote: > > To all people who voted 3. UNRESTRICTED: > > Are you aware that this is a good source for causing nightmares > (as has been discussed previously)? > That's OK. I predict that this proposal passes overwhelmingly, but never gets implemented. Rob has discussed this several times, but I doubt many people realize (because they've never really worked with the source code) how large a change it is to add some new data type. I could be wrong, of course. But really, I don't see what this proposal really adds to the language. The only advantage that I can see is that some of the type checking for certain UDTs can be done by the back end. Of course, if it gets as ingrained as checking for sequence/atom/integer, then it's going to really slow things down, since those checks happen regardless of whether type checking is turned on. And that usually only happens during debugging, not for production, so speed isn't nearly so critical. I think that this is really a false start at some sort of structured data type for euphoria, which would have benefits, because you'd have more ability to do type checks on individual pieces of data and structured access to data members that wouldn't pollute the namespace. That's the sort of thing that would be really useful. Matt
8. Re: Discussion concerning [POLL] Sequences of types
- Posted by Pete Lomax <petelomax at blueyo?d?r.co.uk> Aug 24, 2007
- 674 views
Derek Parnell wrote: > > object names -- Can be assigned with anything. > sequence names -- Can only be assigned with a sequence. > sequence of sequence names -- Can only contain sequences. > sequence of sequence of object names -- same as above. > sequence of sequence of atom names -- Can only contain sequences, which > -- can only contain atoms > sequence of sequence of integer names -- Can only contain sequences, which > -- can only contain integers > > If this is too much for some people to grok then maybe a simplified 'type' > alias > might be useful. > > type word_list (sequence of sequence of integer) > end type > In the name of code readability, I expected you to favour the latter. Both could work, I guess, this may be more a matter of personal preference. Suppose we have a chess program:
sequence of sequence of sequence of integer backtrack_list sequence of sequence of integer init,best,curr,scratch
vs.
type row(sequence of integer r) end type type board(sequence of row b) end type type boards(sequence of board sb) end type board init,best,curr,scratch boards backtrack_list
Now you may or may not not need a Phd in the effect of the spice girls on the global multimedia economy to figure either out, not the point. A possibly important advantage here is that the innermost bit is now quite clearly a row not a column. Another example is:
sequence of sequence of sequence of integer filetable
vs.
type char(integer c) end type type line(sequence of char l) end type type file(sequence of line f) end type type texts(sequence of file sf) end type texts filetable
The clincher for me though is this, for the chess example:
function f(object o) row r if board(o) then r=o[1] ... elsif row(o) then ... end function
How would you test for board or row without a named udt? More subtly, what type do you give r? Yes, you can (easily) figure out from the sequence of sequence of sequence of integer thing that it needs to be a sequence of integer, but you are probably just going to give it type object and then the compiler cannot optimise away any type-checking. Regards, Pete
9. Re: Discussion concerning [POLL] Sequences of types
- Posted by Pete Lomax <petelomax at blu?yonder?co.uk> Aug 24, 2007
- 668 views
Matt Lewis wrote: > > I don't see what this proposal > really adds to the language. The only advantage that I can see is that > some of the type checking for certain UDTs can be done by the back end. Yup. For detailed type checking that is currently completely impractical, however, that is no small thing. > I think that this is really a false start at some sort of structured > data type for euphoria I daresay I agree with you. The current vote is a subset of what has recently been discussed, and hopefully there is more to come. But a start is a start. Regards, Pete
10. Re: Discussion concerning [POLL] Sequences of types
- Posted by Pete Lomax <petelomax at b?u?yonder.co.uk> Aug 24, 2007
- 668 views
Pete Lomax wrote: > > Matt Lewis wrote: > > > > I don't see what this proposal > > really adds to the language. The only advantage that I can see is that > > some of the type checking for certain UDTs can be done by the back end. > Yup. For detailed type checking that is currently completely impractical, > however, > that is no small thing. > Actually I do wonder how many people think this is adding something new and powerful and exciting to the language? All this stuff will ever do is allow you to make your program crash earlier&faster when there is a bug in it. Regards, Pete
11. Re: Discussion concerning [POLL] Sequences of types
- Posted by Matt Lewis <matthewwalkerlewis at g?ail.co?> Aug 24, 2007
- 668 views
Pete Lomax wrote: > > Pete Lomax wrote: > > > > Matt Lewis wrote: > > > > > > I don't see what this proposal > > > really adds to the language. The only advantage that I can see is that > > > some of the type checking for certain UDTs can be done by the back end. > > > > Yup. For detailed type checking that is currently completely impractical, > > however, > > that is no small thing. > > > Actually I do wonder how many people think this is adding something new and > powerful > and exciting to the language? All this stuff will ever do is allow you to make > your program crash earlier&faster when there is a bug in it. Yes, exactly! I can't get my head around the usefulness of this. As I see it, there are two basic reasons to use the euphoria type checking capabilities. One is for debugging, to ensure that data is correct. I don't really see this as hugely benefiting from the speed up, and I also believe that the massive changes required to the interpreter are not worth the minimal benefit. The second is to discriminate between different kinds of data (like your chess boards, board, row example). For deeply nested data that requires a lot of checking, this is probably a poor method. Better would be to tag the data with some kind of metadata to identify what it is (you could still use type checking while debugging). Which explains my 'No' vote. Matt
12. Re: Discussion concerning [POLL] Sequences of types
- Posted by c.k.lester <euphoric at ckleste?.co?> Aug 24, 2007
- 660 views
Pete Lomax wrote: > > Actually I do wonder how many people think this is adding something new and > powerful > and exciting to the language? All this stuff will ever do is allow you to make > your program crash earlier&faster when there is a bug in it. I thought it was a sort of structured variable helper. Won't it make managing structures easier/faster?
13. Re: Discussion concerning [POLL] Sequences of types
- Posted by Matt Lewis <matthewwalkerlewis at gmai?.co?> Aug 24, 2007
- 646 views
Pete Lomax wrote: > > > I think that this is really a false start at some sort of structured > > data type for euphoria > > I daresay I agree with you. > > The current vote is a subset of what has recently been discussed, and > hopefully > there is more to come. But a start is a start. I just think it's a blind alley. I think that what people really want (even if they don't know it yet :P ) is the native ability to have some kind of structured data, but the reason for this is not to enforce types (which can already be done) but to simplify the use of the data. I still believe that the 'euclass' facilities of ooeu are a step in the right direction. One advantage of it is that the changes are all in the front end. Pure vanilla Euphoria IL is emitted (though I think that ultimately there are some things that will require some backend work). It occurred to me today that there's an 'easy' way to store metadata to allow some powerful extensions of this concept without having to change lots of stuff. Currently, the 0th element (seq_ptr->base[0]) of a sequence sits emtpy, but we could put a pointer to a struct of metadata that could hold information to allow better type checking, virtual functions, inheritance, etc. In any case, there's a lot to figure out, but it's at least useful, and, IMHO very worthy of consideration. Matt
14. Re: Discussion concerning [POLL] Sequences of types
- Posted by Juergen Luethje <j.lue at gmx.??> Aug 24, 2007
- 652 views
Pete Lomax wrote: > Pete Lomax wrote: >> >> Matt Lewis wrote: >>> >>> I don't see what this proposal >>> really adds to the language. The only advantage that I can see is that >>> some of the type checking for certain UDTs can be done by the back end. >> Yup. For detailed type checking that is currently completely impractical, >> however, >> that is no small thing. >> > Actually I do wonder how many people think this is adding something new and > powerful > and exciting to the language? All this stuff will ever do is allow you to make > your program crash earlier&faster when there is a bug in it. Well, actually it will also allow programs to run faster when type- checking is switched on and there is no crash. In those cases, debugging would be considerably faster for certain programs. This makes it more convenient for programmers to switch type-checking on for debugging, and so will encourage them to actually do so. This can help to find bugs and so make their programs safer. I think a good overview about the pros and cons is in Robs first post in the current discussion about UDTs: http://www.openeuphoria.org/cgi-bin/esearch.exu?fromMonth=6&fromYear=C&toMonth=8&toYear=C&postedBy=Robert+Craig&keywords=22%3A26+type Regards, Juergen
15. Re: Discussion concerning [POLL] Sequences of types
- Posted by Matt Lewis <matthewwalkerlewis at ?m?il.com> Aug 24, 2007
- 684 views
Juergen Luethje wrote: > > Well, actually it will also allow programs to run faster when type- > checking is switched on and there is no crash. In those cases, debugging > would be considerably faster for certain programs. This makes it more > convenient for programmers to switch type-checking on for debugging, and > so will encourage them to actually do so. This can help to find bugs and > so make their programs safer. > I think a good overview about the pros and cons is in Robs first post in > the current discussion about UDTs: > > http://www.openeuphoria.org/cgi-bin/esearch.exu?fromMonth=6&fromYear=C&toMonth=8&toYear=C&postedBy=Robert+Craig&keywords=22%3A26+type Yes, I agree with that, however, my personal assessment (as someone who has extended/maintained the interpreter) is that the following statement of Rob's dominates the equation: * It seemed at the time to be a fair bit of work, and extra baggage added to the language, for just a small gain. I'm happy to be proved wrong, however. I suppose one nice benefit is that you could do a lot more (in an easier fashion ) at compile time, even in the interpreter, to catch bugs much sooner. Matt
16. Re: Discussion concerning [POLL] Sequences of types
- Posted by Juergen Luethje <j.lue at gm?.d?> Aug 24, 2007
- 661 views
Matt Lewis wrote: > Juergen Luethje wrote: > > > To all people who voted 3. UNRESTRICTED: > > > > Are you aware that this is a good source for causing nightmares > > (as has been discussed previously)? > > > That's OK. I predict that this proposal passes overwhelmingly, but never > gets implemented. > Rob has discussed this several times, but I doubt many > people realize (because they've never really worked with the source code) > how large a change it is to add some new data type. I didn't realize that, too. Of course there should be a reasonable ratio of effort and effect. > I could be wrong, of course. But really, I don't see what this proposal > really adds to the language. The only advantage that I can see is that > some of the type checking for certain UDTs can be done by the back end. > > Of course, if it gets as ingrained as checking for sequence/atom/integer, > then it's going to really slow things down, since those checks happen > regardless of whether type checking is turned on. I doubt that anyone would like that. > And that usually only > happens during debugging, not for production, so speed isn't nearly so > critical. > > I think that this is really a false start at some sort of structured > data type for euphoria, which would have benefits, because you'd have > more ability to do type checks on individual pieces of data and structured > access to data members that wouldn't pollute the namespace. That's > the sort of thing that would be really useful. From several discussions in the past, I think many people (including me) would greatly appreciate to have some sort of structured data type in euphoria. Do you think it's possible to get that without too much effort and trouble? Regards, Juergen
17. Re: Discussion concerning [POLL] Sequences of types
- Posted by Matt Lewis <matthewwalkerlewis at ??ail.com> Aug 24, 2007
- 662 views
Juergen Luethje wrote: > > From several discussions in the past, I think many people (including me) > would greatly appreciate to have some sort of structured data type in > euphoria. Do you think it's possible to get that without too much effort > and trouble? > Yes. I see this as probably the most significant enhancement to the language that's been proposed so far, although I think the 'structured sequence' feature request on sourceforge isn't complete. I think that ooeu made a good start at structured data. Here are a some links to the docs: http://ooeu.sourceforge.net/docs/CLASS_SPECIFICATION.htm http://ooeu.sourceforge.net/docs/DOT_NOTATION.htm Disregard the OOPishness if you like, and omit the routines, at least for now. This could also further the goal of encapsulation (to a point, at least) by limiting the visibility of members/routines of a structure (ooeu doesn't do this). Since the front end would know about the data when it's assigned, we could emit a type check instruction (assuming it's not verifiable at compile time) for the appropriate data type (thus getting the cheaper type checking that the "Sequences of types" proposal seems to give). We also get all the goodness of not having to declare lots of constants for accessing the data. Not to mention that if we had this sort of thing, we could build IDEs with code completion--anyone who's used Visual Studio, Eclipse or some similarly powerful IDE can attest that this is a big helper: reduce typing, errors, coding time. Matt
18. Re: Discussion concerning [POLL] Sequences of types
- Posted by CChris <christian.cuvier at agricul?ur?.gouv.fr> Aug 24, 2007
- 674 views
Pete Lomax wrote: > > Pete Lomax wrote: > > > > Matt Lewis wrote: > > > > > > I don't see what this proposal > > > really adds to the language. The only advantage that I can see is that > > > some of the type checking for certain UDTs can be done by the back end. > > Yup. For detailed type checking that is currently completely impractical, > > however, > > that is no small thing. > > > Actually I do wonder how many people think this is adding something new and > powerful > and exciting to the language? All this stuff will ever do is allow you to make > your program crash earlier&faster when there is a bug in it. > > Regards, > Pete I so dearly wish I had it available when I was debugging the new win32lib structure engine, which has structured sequences whose description is sometimes subtle. Iy would have cut debug time by probably one half, if not more. Counting in weeks. CChris
19. Re: Discussion concerning [POLL] Sequences of types
- Posted by Matt Lewis <matthewwalkerlewis at ?mai?.com> Aug 24, 2007
- 657 views
CChris wrote: > > Pete Lomax wrote: > > > > Actually I do wonder how many people think this is adding something new and > > powerful > > and exciting to the language? All this stuff will ever do is allow you to > > make > > your program crash earlier&faster when there is a bug in it. > > I so dearly wish I had it available when I was debugging the new win32lib > structure > engine, which has structured sequences whose description is sometimes subtle. > Iy would have cut debug time by probably one half, if not more. Counting in > weeks. Could you please explain more fully? Is there a reason why you couldn't have used the existing UDT system? Matt
20. Re: Discussion concerning [POLL] Sequences of types
- Posted by Juergen Luethje <j.lue at ?mx.?e> Aug 24, 2007
- 661 views
- Last edited Aug 25, 2007
Derek Parnell wrote: > Juergen Luethje wrote: > > Say we have something like > > names = {"Tom", "Mary", "Bob"} > > > > If the new syntax is not restricted, then at least each of the following > > would be syntactically correct: > > object names > > sequence names > > sequence of sequence names > > sequence of sequence of object names > > sequence of sequence of atom names > > sequence of sequence of integer names > > Yes, they are all syntactically correct, but each has a different semantics. > > object names -- Can be assigned with anything. > sequence names -- Can only be assigned with a sequence. > sequence of sequence names -- Can only contain sequences. > sequence of sequence of object names -- same as above. > sequence of sequence of atom names -- Can only contain sequences, which > -- can only contain atoms > sequence of sequence of integer names -- Can only contain sequences, which > -- can only contain integers I know that each one has a different semantics, but that's not my point. > If this is too much for some people to grok then maybe a simplified 'type' > alias > might be useful. > > type word_list (sequence of sequence of integer) > end type We do not need an alias mechanism if we do things properly in the first place. Only allowing the new syntax in type definitions like this was the core of Pete's proposal. > > and maybe even > > object of sequence names > > object of sequence of object names > > object of sequence of atom names > > object of sequence of integer names > > Well, the above would not be valid Maybe, maybe not. We can't know that for sure until it would be implemented. > as they don't start with "sequence". > > > > or > > sequence of object names > > sequence of object of object names > > sequence of object of atom names > > sequence of object of integer names > > However, 'sequence' by itself is already an abbreviation for 'sequence of > objects'. > > > This is very confusing, especially for beginners, and has IMHO nothing > > got to do with the spirit of Euphoria. > > If its the wordiness that worries you then we can solve that with an alias > mechanism. One problem is that it can reduce redability. Things like object foo sequence bar etc. can be read quickly and reliably at one glance. This is not the case for variable declarations like above, especially since there are _many_ different possibilities to declare the same variable. Another problem is that it has a good potential to cause confusion. Imagine a newbie who wants to declare 'names'. Which of the available 14 (or 18, that doesn't matter) options should s/he use? > And exactly what is "the spirit of Euphoria"? You know very well that it's not possible to give an exact definition of it. However, there is something like that. You can call it the "core principles of Euphoria" or something similar, if you prefer. Certainly _not_ among the core principles of Euphoria is making things unnecessarily complicated, confusing newbies, and providing lots of different options for the same thing. Actually one of Euphoria's principles is to reduce the number of choices which the programmer has to made. This is what makes the language simple, clean and good readable. For everyone who is seriously interested in this matter, I can recommend an interesting lecture by Prof. Barry Schwartz: The Paradox of Choice - Why More Is Less (April 27, 1006). [video, about 1 hour] <http://video.google.com/videoplay?docid=6127548813950043200> > > That's why Pete Lomax suggested to restrict the new syntax to the > > definition of types. Then w'd have to create a user-defined type say > > "word_list", and in our programs we just say: > > word_list names > > Like the simplified alias syntax I suggested above? Yes. Well, in the meantime Pete has replied himself. > > I'm strongly against the introduction of the new type syntax without > > this restriction. > > I don't really think that this concept, which is used in other languages, is > all that baffling to newbies and oldbies alike. I don't know any other language that provides 14 or 18 different possibilities for declaring the same variable. Regards, Juergen
21. Re: Discussion concerning [POLL] Sequences of types
- Posted by Derek Parnell <ddparnell at ?igpond.c?m> Aug 25, 2007
- 704 views
Juergen Luethje wrote: > > Derek Parnell wrote: > > > Juergen Luethje wrote: > > > Say we have something like > > > names = {"Tom", "Mary", "Bob"} > > > > > > If the new syntax is not restricted, then at least each of the following > > > would be syntactically correct: > > > object names > > > sequence names > > > sequence of sequence names > > > sequence of sequence of object names > > > sequence of sequence of atom names > > > sequence of sequence of integer names > > > > Yes, they are all syntactically correct, but each has a different semantics. > > > > object names -- Can be assigned with anything. > > sequence names -- Can only be assigned with a sequence. > > sequence of sequence names -- Can only contain sequences. > > sequence of sequence of object names -- same as above. > > sequence of sequence of atom names -- Can only contain sequences, which > > -- can only contain atoms > > sequence of sequence of integer names -- Can only contain sequences, which > > -- can only contain integers > > I know that each one has a different semantics, but that's not my point. I think that you are saying that each of these things are equivalent to each other and thus there is multiple ways to declare the same 'type' of variable, and this is potentally confusing. However I am saying that these are not the same 'type' of variable. That each one is a different type. As different as one can find in C, for example ... int names; long names; char* names; char[45] names; float names; Semantics is what makes them different. To further emphasize my point, if one were to imlement the same functionality in current Euphoria, one would use UDT, thus demonstrating that they are actually different types.
type SoS(object x) -- Can only contain sequences. if not sequence(x) return 0 end if for i = 1 to length(x) do if not sequence(x[i]) return 0 end if end for return 1 end type type SoSoO(object x) -- Can only contain sequences, which -- can only contain objects if not sequence(x) return 0 end if for i = 1 to length(x) do if not sequence(x[i]) return 0 end if for j = 1 to length(x[i]) do if not object(x[i][j]) then return 0 end if end for end for return 1 end type type SoSoA(object x) -- Can only contain sequences, which -- can only contain atoms if not sequence(x) return 0 end if for i = 1 to length(x) do if not sequence(x[i]) return 0 end if for j = 1 to length(x[i]) do if not atom(x[i][j]) then return 0 end if end for end for return 1 end type type SoSoI(object x) -- Can only contain sequences, which -- can only contain integers if not sequence(x) return 0 end if for i = 1 to length(x) do if not sequence(x[i]) return 0 end if for j = 1 to length(x[i]) do if not integer(x[i][j]) then return 0 end if end for end for return 1 end type object names -- Can be assigned with anything. sequence names -- Can only be assigned with a sequence. SoS names -- Can only contain sequences. SoSoO names -- Can only contain sequences that only contain objects SoSoA names -- Can only contain sequences that only contain atoms SoSoI names -- Can only contain sequences that only contain integers
So you see if the proposal is confusing then Euphoria is already just as confusing. > > If this is too much for some people to grok then maybe a simplified 'type' > > alias > > might be useful. > > > > type word_list (sequence of sequence of integer) > > end type > > We do not need an alias mechanism if we do things properly in the first > place. Only allowing the new syntax in type definitions like this was > the core of Pete's proposal. But WHY? It takes more typing, more reading and achieves nothing extra. > > > and maybe even > > > object of sequence names > > > object of sequence of object names > > > object of sequence of atom names > > > object of sequence of integer names > > > > Well, the above would not be valid > > Maybe, maybe not. We can't know that for sure until it would be > implemented. Hmmm... think about it a bit more. An "object of sequence" is an object that must only be assigned with a sequence as the left hand side expression. Thus it is identical to what we now call a "sequence". Thus "object of sequence" is longhand for "sequence". > > as they don't start with "sequence". > > > > > > > or > > > sequence of object names > > > sequence of object of object names > > > sequence of object of atom names > > > sequence of object of integer names > > > > However, 'sequence' by itself is already an abbreviation for 'sequence of > > objects'. > > > > > This is very confusing, especially for beginners, and has IMHO nothing > > > got to do with the spirit of Euphoria. > > > > If its the wordiness that worries you then we can solve that with an alias > > mechanism. > > One problem is that it can reduce redability. Things like > object foo > sequence bar > etc. can be read quickly and reliably at one glance. This is not the > case for variable declarations like above, Oh I agree that it would be poor coding practice for people to do any more than one level of 'X of Y' just on legibilty grounds. However, conceptually there is nothing wrong with the idea so therefore a shorthand 'alias' would enable both the concept and the practically of coding it to co-exist. > especially since there are > _many_ different possibilities to declare the same variable. See above. They are not the 'type' so they are not declaring the same (way to use the) variable. Literally "different possibilities to declare the same variable" is already present in the language. eg.
object names sequence names integer names atom names myUTD names
These above all declare the same variable (name) but with different semantics. > Another problem is that it has a good potential to cause confusion. > Imagine a newbie who wants to declare 'names'. Which of the available > 14 (or 18, that doesn't matter) options should s/he use? The one that implements the semantics that they desire for their application. That was an easy one. > > And exactly what is "the spirit of Euphoria"? > > You know very well that it's not possible to give an exact definition of > it. That was exactly my point. It isn't possible because when we get to the detail level everyone has a different opinion. > However, there is something like that. You can call it the "core > principles of Euphoria" or something similar, if you prefer. > > Certainly _not_ among the core principles of Euphoria is ... > making things unnecessarily complicated, if compare(Seq1, Seq2) < 0 then ... (Yeah, that is much more simplier than "if Seq1 < Seq2 then ... ") > confusing newbies, See above... > and providing lots of > different options for the same thing. if equal(A,B) then ... if compare(A,B) = 0 then ... if A = B then ... > Actually one of Euphoria's principles is to reduce the number of choices > which the programmer has to made. This is what makes the language simple, > clean and good readable. Does this also mean that the langauge with fewer choices is the better one? What think ye of Forth? Or BrainFuck? > > I don't really think that this concept, which is used in other languages, is > > all that baffling to newbies and oldbies alike. > > I don't know any other language that provides 14 or 18 different > possibilities for declaring the same variable. Try C/C++ -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
22. Re: Discussion concerning [POLL] Sequences of types
- Posted by Robert Craig <rds at RapidEupho?i?.com> Aug 25, 2007
- 656 views
I'm giving it a mild YES. I think it would be pretty easy to add the necessary front-end parsing to collect up the number of "sequence of"'s and add this number as a field in the symbol table. Doing the extra type checking in the interpreter, in a fairly efficient way, would be a bit more work. I have to admit I was flip/flopping between YES and NO today, for the reasons I mentioned earlier. One issue that bothered me was performance. If it turned out that this feature was still causing a lot of O(1) code to become O(n), then the feature might get a bad name and people might avoid it, or feel that type_check should always be turned off in any large program. Once typical example that was on my mind was a routine declared to take "sequence of integer" and an argument being passed that was only declared as "sequence", or was the result of an expression. You'd have to check that whole sequence on each call. Though typically, each element of the sequence would at least be "looked at" inside the routine, so it would not necessarily go from O(1) to O(n), but it still worried me a bit. I thought of some ways to improve performance however, such as perhaps employing an optimization in the interpreter that I've almost put in before. At run-time it would tag each sequence as being "all integers" until such time as a non-integer is assigned (so there would be no extra cost when an integer is assigned). I toyed with this optimization before because it would save time on DeRefing a sequence when it becomes garbage. Currently the interpreter must scan each sequence for non-integers that must also be DeRef'd. If we start having lots of "sequence of integer" declarations, the optimization would help with that as well, making them O(1). There are other optimizations that the interpreter might also do, although the interpreter is not nearly as "smart" as the Translator in computing the type of intermediate results at compile-time. I'm hoping other people will be the ones to actually implement most of this, if it goes ahead. Perhaps I'd be the one to improve the Translator code quality by taking advantage of the extra type info. I find the Translator is very complicated and fragile, even for me, the guy who wrote it. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
23. Re: Discussion concerning [POLL] Sequences of types
- Posted by Juergen Luethje <j.lue at gm??de> Aug 25, 2007
- 674 views
Derek Parnell wrote: > > Juergen Luethje wrote: > > > > Derek Parnell wrote: > > > > > Juergen Luethje wrote: > > > > Say we have something like > > > > names = {"Tom", "Mary", "Bob"} > > > > > > > > If the new syntax is not restricted, then at least each of the following > > > > would be syntactically correct: > > > > object names > > > > sequence names > > > > sequence of sequence names > > > > sequence of sequence of object names > > > > sequence of sequence of atom names > > > > sequence of sequence of integer names > > > > > > Yes, they are all syntactically correct, but each has a different > > > semantics. > > > > > > object names -- Can be assigned with anything. > > > sequence names -- Can only be assigned with a sequence. > > > sequence of sequence names -- Can only contain sequences. > > > sequence of sequence of object names -- same as above. > > > sequence of sequence of atom names -- Can only contain sequences, which > > > -- can only contain atoms > > > sequence of sequence of integer names -- Can only contain sequences, > > > which > > > -- can only contain integers > > > > I know that each one has a different semantics, but that's not my point. > > > I think that you are saying that each of these things are equivalent to each > other No. I didn't say that. Just read my post carefully. It's understandable. In order to understand the "whole story", it's probably necessary to watch the video that I recommended. Regards, Juergen
24. Re: Discussion concerning [POLL] Sequences of types
- Posted by Igor Kachan <kinz at pete?lin?.ru> Aug 25, 2007
- 672 views
Robert Craig wrote: > > I'm giving it a mild YES. > > I think it would be pretty easy to add the necessary > front-end parsing to collect up the number of "sequence of"'s > and add this number as a field in the symbol table. > Doing the extra type checking in the interpreter, > in a fairly efficient way, would be a bit more work. [snip] Ok, if you like this idea (sorry, me do not), let me please to suggest yet another syntax for it, namely: sequence_i -- i is sign of integer (in current documentation) sequence_a -- a is sign of atom sequence_s -- s is sign of sequence sequence_s_s_s_s_s_i sequence_s_s_a or sequence_8_s_i or sequence_8i sequence_3a All these cases seem to be very special and too professional and I do not think they require a separate key word, "of", for better ungerstanding of a program text. Maybe, I'd like to see them even as one of some surprise features in separate section of docs Just my $0.02. Good Luck! Regards, Igor Kachan kinz at peterlink.ru
25. Re: Discussion concerning [POLL] Sequences of types
- Posted by Juergen Luethje <j.lue at gm?.?e> Aug 25, 2007
- 665 views
Matt Lewis wrote: > Juergen Luethje wrote: > > > > From several discussions in the past, I think many people (including me) > > would greatly appreciate to have some sort of structured data type in > > euphoria. Do you think it's possible to get that without too much effort > > and trouble? > > > Yes. I see this as probably the most significant enhancement to the language > that's been proposed so far, although I think the 'structured sequence' > feature request on sourceforge isn't complete. > > I think that ooeu made a good start at structured data. Here are a some > links to the docs: > > <a > href="http://ooeu.sourceforge.net/docs/CLASS_SPECIFICATION.htm">http://ooeu.sourceforge.net/docs/CLASS_SPECIFICATION.htm</a> > <a > href="http://ooeu.sourceforge.net/docs/DOT_NOTATION.htm">http://ooeu.sourceforge.net/docs/DOT_NOTATION.htm</a> > > Disregard the OOPishness if you like, and omit the routines, at least for > now. This could also further the goal of encapsulation (to a point, at > least) by limiting the visibility of members/routines of a structure > (ooeu doesn't do this). > > Since the front end would know about the data when it's assigned, we could > emit a type check instruction (assuming it's not verifiable at compile time) > for the appropriate data type (thus getting the cheaper type checking that > the "Sequences of types" proposal seems to give). > > We also get all the goodness of not having to declare lots of constants > for accessing the data. Not to mention that if we had this sort of thing, > we could build IDEs with code completion--anyone who's used Visual Studio, > Eclipse or some similarly powerful IDE can attest that this is a big > helper: reduce typing, errors, coding time. > > Matt Cool! That sounds exciting. Regards, Juergen
26. Re: Discussion concerning [POLL] Sequences of types
- Posted by Peter Robinson <indorlaw at y?hoo?com.au> Aug 26, 2007
- 683 views
Hi all Discussion on the poll appears to have finished, so I'll publish the results shortly. Anyone can still vote, or even change their vote, if they wish. Another poll will follow in due course. Regards PR
27. Re: Discussion concerning [POLL] Sequences of types
- Posted by DB James <larches at comcast.n?t> Aug 27, 2007
- 666 views
Have been distracted, computer died, resurrection fraught, voting: YES A UNRESTRICTED UNRESTRICTED UNRESTRICTED --Quark