On Tue, Jul 13, 2010 at 12:37 AM, Burcin Erocal <[email protected]> wrote:
> Hi Robert,
>
> On Mon, 12 Jul 2010 22:52:24 -0700
> Robert Bradshaw <[email protected]> wrote:
>
>> > As for syntax, I think the slice syntax is clever and fairly
>> > intuitive.  I can also understand using brackets to access operands
>> > in an expression.  Personally, I think the brackets make more sense
>> > for indexing, but they would probably see more use for operand
>> > access.  It wouldn't bother me to use an ``indexed()`` method
>> > instead.  I would be happy to review a patch to add either one.
>>
>> I like the slice syntax as well. I think it'd be nice to reserve the
>> __getitem__ notation for subscripts.
>
> We don't have to use __getitem__ to have access to the slice notation.
> I suggest keeping __getitem__ to index operands of an expression and
> adding an .index property, which provides __getitem__, to get indexed
> expressions. For example:
>
> sage: var('x,y,z')
> (x, y, z)
> sage: t = x+y+z; t
> x + y + z
> sage: t[0]
> x
> sage: t[1:]
> [y, z]
> sage: x.index[i:3] #indexed expression
> x.i
>
>
> Comments?

I was thinking

sage: latex(x[1], x[2], x[i])
(x_1, x_2, x_i)

The index notation would be a convenient way to get many new (related)
variables, much cleaner IMHO than creating a string to pass to vars. I
think this is what Mathematica and/or Maple to as well.

I think indexing into operands by number is a bit brittle, and
x.operands()[2] is much more explicit.

- Robert

-- 
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to