[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] ideas from ruby and clean




On Dec 9, 2004, at 8:17 PM, ccos wrote:


in ruby (1..4) gives a range much like sc's current array notation but you can also go

(1...4) giving [1,2,3]

my inclination is to say just put a -1 there. this would create several methods and about 15 new cases in the compiler.
for consistency you'd have to support
x[1...4]
x[1...4] = z
etc.


unrelated, but more interesting, in clean language you can write [n..]:

which in sc could be written (n..) returning

I think it would be confusing to have (0..4) return an array but (0..) return a stream. and what if you wanted a stream from 0 to 4 ?
better to have distinct syntaxes for each.
[n..] has parsing conflicts. {n..} doesn't work either. you'd have to do something like (.n..) or (*n..) SC is more oriented around patterns than streams. Perhaps a syntax for patterns would be more useful.


	r {
		loop {
			yield(n);
			n = n + 1;
		}
	}

http://www.cs.ru.nl/~clean/About_Clean/tutorial/tutorial.html

kind of cool,
_c


_______________________________________________
sc-dev mailing list
sc-dev@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-dev