(i'm about to launch into an unfounded ramble through ideas, which may
not go anywhere useful. feel free to skip to that much more
interesting email from your significant other)
Intervals do indeed sound cool. Tell me, is there any reason the same
funkiness couldn't be applied to arrays?
array1 = [3, 5, 7, 11, 13, 17, 23]
array2 = 4 array1
Alternatively, have you thought of pinching perl 6's hyper ops?
array2 = 4 * ^array1
In fact, when you start to introduce values which are vectors,
matrices, complex numbers and so on, you suddenly have a huge variety
of not-so-real numbers, any pair of which could be fed into any of the
standard mathematical operators and expected to "just work". Maybe i'm
being a little unfair - such a thing would be a bitch and a half to
implement, whatever the syntax.
(i can't actually remember much real frink syntax, nor have i followed
perl 6 in about six months, meaning it's probably all wrong. forgive
me)
I don't like the idea of i[3, 5], any more than new Interval[3, 5].
They both seem somehow ugly, and not just because it interferes with
normal multiplication by i. The options that seem more pleasing to my
eye are the ones like [3 something 5], only with a smaller and more
visible character clump in between. Tell, what would frink currently
make of the following?
[3 .. 5]
[3 . 5]
[3 ~ 5]
[3 -- 5]
[3 _ 5]
My intuition (she is a harsh mistress) says that they should mean:
[3 .. 5] => the array [3, 4, 5]
[3 . 5] => something to do with 5 being a member of the 3 object
(which make her very unhappy)
[3 ~ 5] => she thinks ~ looks like some existing mathematical
operator, but doesn't know what, but it expects that to mean the
one-element array containing the result of that calculation
[3 -- 5] => a comment after the 3
[3 _ 5] => she doesn't quite know. good candidate?
It also needs to be something that allows the inclusion of a middle
value. Something like this:
[3 _ 4 _ 5]
Does that work for you?
Thinking about it, the array brackets are starting to look slightly
superfluous - and more to the point, they're encouraging me to think
of things like:
[3 _ 5, 4 _ 6]
So my brain clearly thinks that these are perfectly valid ways to do intervals:
x = 3 _ 5
y = 3 _ 4 _ 5
But it's probably wrong. Is there a good reason you want to use array
brackets, not group brackets? This actually seems like a perfect
instance where what you're defining is a grouped calculation,
producing one value rather than a list:
x = (3 _ 5)
y = (3 _ 4 _ 5)
Returning to my thought earlier, it seems like group brackets might
have other uses:
complex = (3 + 4i)
interval = (3 _ 5)
interval2 = (3 _ 4 _ 5)
vector = (3, 4)
matrix = (3, 4; 5, 6)
or somesuch. all of which may be pretty, but will very quickly become
ambiguous. The slightly ugly thought occurs to me of using a keyword
inside the brackets like this:
complex = (3 + 4i) // this really is just calculated, not constructed
interval = (interval 3, 5)
interval2 = (interval 3, 4, 5)
vector = (vector 3, 4)
matrix = (matrix 3, 4; 5, 6)
But i'm sure you'll reject that as being a corruption of the currently
nice and pure group brackets.
Anyway. That lot wasn't really an answer. Do i win? Or do i just need
to go get some sleep?