Re: Wierd Language Syntax idea
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Jun 04, 1998
- 616 views
>And by the way, I want to be able to do > >{x,y} = foo() This and you other suggestion can be solved by the programming method the language ICON uses. Consider this ICON function (in EUphoria pseudo-code): function for (integer begin, integer end, integer step) do return begin if end > begin then begin = begin + step return begin end if end function sequence txt txt = "This is a message" puts (1, txt) -- Will print the first character of txt all puts (1, txt) -- Keeps streaming txt until it returns no more value -- Thus: it prints the whole txt sequence all for(1,10,1) do puts (1, txt) end do -- Will display the first 10 characters of txt only once! Why ? Lets trace it. First the for () statement will return 1, then the first character is displayed. the 'ALL' means we don't stop until we no longer have any arguments to use. So it will print a character of txt 10 times. A bit more of this strange, but powerfull, behaviour. all txt = 'e' do puts(1, "X") else puts(1, "*") end do Will display: ***********X****X How can this solve your {x,y} assignment problem. Simple: It doesn't need any assigns at all. Using this streaming technique, you could put *any* algoritm in a single statement containing your whole program. How explecit can one be ? Just search for ICON PROGRAMMING LANGUAGE The language itself, is really shitty, very slow, weird unneeded datatypes, etc. But this aspect could inspire us. We really don't like to assign every thing, check its value or stuff like that. This would solve it. >and to be able to evaluate > >{{1,2},{3,4},{5,6}} * {x,y} Yes, it would be nice if this worked! Robert, if sequences don't match, they should go a level deeper until they do. It would be more powerfull behaviour. BTW what about being able to say: sequence s s = {4,4,5,5,2} if +s != 20 then puts(1, "that's weird when I add 4, 4, 5, 5 and 2 together I *do* have 20") end if And like +sequence_name, why not also have -seq_name and *seq_name and /seq_name Ralf