1. sequence OF what? - structores
- Posted by "Unkmar" <L3Euphoria at bellsouth.net> Jun 04, 2004
- 479 views
Only thing I can figure you can get out of that is. Very fixed, non-dynamic typing. I know, you say, What? Using OF how would you type handle this?
sequence pb pb = {"Johnny", "Robert", "Princeton", "Jr.", 12, 31, 1977, 150, "blue", "blonde", 6, 2, 'M'}
---- I stand by my proposal... or should I say Chris Bensler's proposal of structures. Maybe, someone mentioned before him. I wouldn't doubt it. Either way. Something like this can handle it. ----}}} <eucode> type month(object x) if (integer(x) and (12 >= x and x >=1)) then return 1 else return 0 end if end type type mday(object x) if (integer(x) and (31 >= x and x >=1)) then return 1 else return 0 end if end type type year(object x) if (integer(x) and (1890 >= x and x >=3000)) then return 1 else return 0 end if end type type weight(obect x) if (atom(x) and (2000 >= x and x >=0)) then return 1 else return 0 end if end type type byte(object x) if (integer(x) and (255 >= x and x >=0)) then return 1 else return 0 end if end type type feet(object x) if (integer(x) and (10 >= x and x >=0)) then return 1 else return 0 end if end type type inches(object x) if (integer(x) and (12 >= x and x >=0)) then return 1 else return 0 end if end type type gender(object x) if (integer(x) and find(x, "MFUmfu")) then return 1 else return 0 end if end type -- Hmm, I haven't thought of a way for handling a dynamic length item using struct type string(object x) if (sequence(x)) then for A = 1 to length(x) do if (not byte(x[A]) then return 0 end if end for return 1 else return 0 end if end type struct PhoneBookItem {string, string, string, string, month, mday, year, string, string, feet, inches, gender} end struct </eucode> {{{ unkmar ----------------- Complete message by Patrick Barnes is at http://www.listfilter.com/cgi-bin/esearch.exu?postedBy=Barnes&keywords=myDat aStructure ----- Original Message ----- From: "Patrick Barnes" <mistertrik at hotmail.com> To: <EUforum at topica.com> Sent: Monday, May 31, 2004 7:08 PM Subject: Re: Stupid Newbie-sounding question. > We need a new keyword; "of". > Usage: > > type char ( integer c ) > -- return 1 valid character, 0 otherwise > end type > > --myStr is a string > sequence of char myStr > <snip> > > If you have a complex data structure list, you could have: > > type myDataStructure( sequence s) > --return 1 if valid myDataStructure, 0 otherwise > end type > > sequence of myDataStructure master_list > <snip> > Multi-dimensional arrays are also possible: > > --2d array of integers > sequence of sequence of integer 2d_array > > type textpict_line( sequence s) > if length(s) = 80 then return 1 > else return 0 > end if > end type > > --2d array where the length of each line is fixed, and consists of > characters > sequence of textpict_line of char text_picture > > <snip>> > type rgb (sequence of integer c) > return length(c) = 3 > end type > > type rgb_map ( sequence of sequence of rgb x) > return 1 > end type > > If no extra checking has to be done, then the type just returns 1. > <snip> > Cheers. > MrTrick
2. Re: sequence OF what? - structores
- Posted by "Unkmar" <L3Euphoria at bellsouth.net> Jun 04, 2004
- 477 views
http://www.listfilter.com/cgi-bin/esearch.exu?keywords=%22end+struct%22 I Looked back through some of that history of structure suggestions.
type char(object x) if (integer(x) and (255 >= x and x >= 0) then result 1 else result 0 end if end type
char my_string[] my_string = "Hello" my_string = {-1, 45} -- error because -1 isn't a char stuct Address street as char[40] city as char[30] state as char[2] zip as char[5] end struct OR stucture Address street as char(40) city as char(30) state as char(2) zip as char(5) end structure Just take a look at the link I supplied. It shows that this subject as been beat to death before. And this link displays Rob's view on structures and some of what we have been asking for. http://www.listfilter.com/cgi-bin/esearch.exu?postedBy=Craig&keywords=struct ures I'll shut up now unkmar ----- Original Message ----- From: "Patrick Barnes" <mistertrik at hotmail.com> To: <EUforum at topica.com> Sent: Thursday, June 03, 2004 10:00 PM Subject: RE: sequence OF what? - structores >From: Lucius Hilley <l3euphoria at bellsouth.net> >Subject: sequence OF what? - structores >Only thing I can figure you can get out of that is. >Very fixed, non-dynamic typing. >I know, you say, What? Actually, I know what you mean. It's supposed to be fixed. Most of the variables we use will be aggregates, long sequences containing lots of the same type of value. Unfortunately, at the moment traditional type checking is horribly slow. A 2 element sequence wouldn't take long, but to check a 1000-element sequence is too slow, cause traditional type checking has to check every single element every time something changes. I don't mean for the 'of' keyword to be appropriate for structures, that is a separate issue, and totally transparent to the idea of "of". >Using OF how would you type handle this? >}}} <eucode> >sequence pb > >pb = {"Johnny", "Robert", "Princeton", "Jr.", 12, 31, 1977, 150, "blue", >"blonde", 6, 2, 'M'} ></eucode> {{{ As I said above, "of" doesn't affect structures at all. For an individual element comprised of different types of values, a traditional type check would need to be used. However, for the sequence comprised of these structures:
type PhoneBookItem( sequence s ) ... normal type checking, make sure that each value is ok ... end type type addressbook (sequence of PhoneBookItem s) return 1 end type addressbook directory directory = {} directory &= {pb}
>---- >I stand by my proposal... or should I say Chris Bensler's proposal of >structures. >Maybe, someone mentioned before him. I wouldn't doubt it. Either way. >Something like this can handle it. <SNIP> >}}} <eucode> >struct PhoneBookItem > {string, string, string, string, month, mday, year, string, string, >feet, >inches, gender} >end struct ></eucode> {{{ As you said, you don't know what to do with strings :oP I don't know exactly what the best thing to do is regarding structures, but if they become a type, then they can be used by the "of" system. No problem. I don't mean to add anything new to the language as far as language enhancements. The thing that "of" does, and the only thing that of does, is allow user defined types to be USEFUL for anything other than simple things. MrTrick
3. Re: sequence OF what? - structores
- Posted by "Patrick Barnes" <mistertrik at hotmail.com> Jun 04, 2004
- 482 views
>From: Lucius Hilley <l3euphoria at bellsouth.net> >I Looked back through some of that history of structure suggestions. > >Just take a look at the link I supplied. >It shows that this subject as been beat to death before. >And this link displays Rob's view on structures and >some of what we have been asking for. Well, the "OF" is completely independant of the idea of structures. It's not the same thing at all. MrTrick
4. Re: sequence OF what? - structores
- Posted by irv mullins <irvm at ellijay.com> Jun 04, 2004
- 464 views
Unkmar wrote: > > Just take a look at the link I supplied. > It shows that this subject as been beat to death before. > And this link displays Rob's view on structures and > some of what we have been asking for. > > <a > href="http://www.listfilter.com/cgi-bin/esearch.exu?postedBy=Craig&keywords=struct">http://www.listfilter.com/cgi-bin/esearch.exu?postedBy=Craig&keywords=struct</a> > ures Yes, I read that. There are some logical inconsistencies there, you can find them for yourself. While we're at it, let me prove why my rusty Ford Pinto is the *best car in the world*: Lowest monthly payments ($0), unlikely to be stolen (unlike those bloated Mercedes), uses almost no gas at all (won't start) cannot roll over (unless I get it started). Regards, Irv