Sequence of Suggestion (was Re: The Title Should At Least Mention Strings (was Re: Stupid Newbie-sounding q
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jun 01, 2004
- 650 views
On Tue, 01 Jun 2004 11:16:22 +1000, Patrick Barnes <mistertrik at hotmail.com> wrote: >My view on this is: > >IT DOESN'T MATTER! THEN CHANGE THE SUBJECT TITLE!) (scnr) <snip> >> >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 >> > >>One of the (deeply technical) problems I have with this approach is >>that if text_picture[3] is updated, and textpict_line(text_picture[3]) >>returns true, should we then call char() 80 times? In the example you >>post, yes, in general, no. (And it is the no case that should clearly >>be pursued to enhance performance). > >So, what are we assigning to text_picture[3] ? An expression. Think of what you might do with a text_picture. You might invert all the characters for a blink effect, or slice and dice to rotate, pan, or zoom the image. You might, for example, code text_picture[3]=upper(text_picture[3]), or you might code text_picture[3]=text_picture[3][2..80]&text_picture[3][1] In both those cases, what is actually assigned is a function result (upper() and concat()), which could be an object of any type, as far as any non-sentient interpreter is concerned. > If it's being assigned to >something that has the type textpict_line already, then we don't need to >type check the element, because it has already been type checked when it was >last changed. That is very important, however allowing "<udt> of" ruins it: type textpict_line( sequence s) if length(s) != 80 then return 0 end if return 1 end type sequence of textpict_line of char text_picture textpict_line somevar somevar=repeat({0,0},80) -- OK text_picture[3]=somevar -- Erm... Here we assign a textpict_line to a textpict_line, so we don't need to do any type checking right? Wrong, of course. >I really think this would make Euphoria more flexible... Oh, I'm not arguing against this, I think it would be good. Just trying to nail down the details & quieten the grumbles in the back of my head. I cannot prove it, but my gut feeling is that allowing a second (or third..) "of" spanners it. Pete PS I am aware that defining somevar as a textpict_line of char will solve the immediate problem.