The Matrix to end all Matrix classes (Let's dream!)

Bill Baxter dnewsgroup at billbaxter.com
Tue Nov 20 19:11:21 PST 2007


Ary Borenszweig wrote:
> Robert DaSilva escribió:
>> Bill Baxter wrote:
>>> Dan wrote:
>>>> D's slices already perform 90% of the stuff we want in order to
>>>> achieve a Matrix.  You more or less just want a standard library that
>>>> lets you do it, right?
>>> I'd say it lets you do about 50% of the stuff you want for a Matrix, but
>>> putting a single percentage figure on it is not really possible, because
>>> different features have different importance to different users.
>>>
>>> In particular:
>>> 1) $ can't be used for opIndex or opSlice in user-classes.
>>
>> I think there's a proposal for that already.
>>
>>> 2) D lacks a clean syntax for slices of multiple dimensions.  opSlice
>>> calls must have one and only one ".."
>>
>> Can you propose a syntax for that?
> 
> [1 .. 2, 3 .. 4]

:-) What about the other end?  How do you define the opSlice that gets 
called by every possible combination of N-dimensional slices and indices 
like
    [1..2, N, 4..7]

One way to extend the current syntax would be if there's any .., in an 
argument then all arguments are treated as slices, and a single number 
argument would be treated as N..N+1.  So the above would call 
opSlice(1,2, N,N+1, 4,7)

Another more general solution would be to have 1..2 result in a slice 
object.  So the above would be like calling 
opSlice(slice(1,2),slice(N,N+1),slice(4,7))

--bb



More information about the Digitalmars-d mailing list