Protecting special names against assignation

2 views
Skip to first unread message

Oscar Gerardo Lazo Arjona

unread,
Feb 20, 2010, 7:21:54 PM2/20/10
to sage-...@googlegroups.com
Some time ago I suggested in sage-support
(http://groups.google.com/group/sage-support/browse_thread/thread/b391ed6bd14cdfd0)

I'd like to propose that certain special names should be protected so
that they could not become variable names (for example pi, e, and i)

if by accident you assign them like:

e=factorial(10)

and then you need to need to use e with it's standard meaning, like

e^100

you will have a very hard to spot error ( (factorial(10)^100).

In that occation I did not create a ticket, but now I have:

http://trac.sagemath.org/sage_trac/ticket/8317

and the thread is better placed in sage-support

thanks!

Oscar

Tom Boothby

unread,
Feb 20, 2010, 7:57:07 PM2/20/10
to sage-...@googlegroups.com
I vehemently oppose this.

-1

I've used pi for: partitions, p[i] where p is a list, etc.
e can be a small error term, a sign, an exponent
i is the best index variable name ever invented, hands down.

That said, I was opposed to implicit multiplication, too. If this is
made into a "mode", then that's fine by me.

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

Andrey Novoseltsev

unread,
Feb 20, 2010, 8:07:15 PM2/20/10
to sage-devel
I am against such restrictions, what if I don't care about complex
numbers and want to use i as an index variable? What if I want e to
stand for an edge?

When I do want to have i^2=-1, I will write the code appropriately,
and if I manage to use the same name for two objects I am working with
- I think it is my fault, I should resolve it, and avoid repeating it
in the future.

Andrey

On Feb 20, 5:21 pm, Oscar Gerardo Lazo Arjona


<algebraicame...@gmail.com> wrote:
> Some time ago I suggested in sage-support

> (http://groups.google.com/group/sage-support/browse_thread/thread/b391...)

Oscar Lazo

unread,
Feb 20, 2010, 8:20:23 PM2/20/10
to sage-devel
On 20 feb, 18:57, Tom Boothby <tomas.boot...@gmail.com> wrote:
> I vehemently oppose this.
>
> -1

I thought it was obvious that this meant to be an optional feature.
Making this forceful would obviously break lot's of previous code. I
thought of it as somethig you could set for individual sage sessions
or for all of them *if you want to*...

thanks

Oscar

William Stein

unread,
Feb 20, 2010, 8:22:35 PM2/20/10
to sage-...@googlegroups.com
On Sat, Feb 20, 2010 at 4:57 PM, Tom Boothby <tomas....@gmail.com> wrote:
> I vehemently oppose this.
>
> -1
>

OK, I'm with you that this will not be on by default. As you suggest
below, this is something that can (and will) be made an optional mode.
We'll have several -- implicit multiplication, automatic variable
name creation, and protected names. Having them all on could be useful
for people teaching, e.g., calculus labs. This protected mode, by
the way, will in the long run use the same technique as automatic
variable name creation: replacing the globals() dictionary by a
customized wrapper. This has a slight performance penalty, so
definitely can't be the default. But it is a fine idea for an
optional mode.

--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

Dr. David Kirkby

unread,
Feb 20, 2010, 8:46:59 PM2/20/10
to sage-...@googlegroups.com
William Stein wrote:
> On Sat, Feb 20, 2010 at 4:57 PM, Tom Boothby <tomas....@gmail.com> wrote:
>> I vehemently oppose this.
>>
>> -1
>>
>
> OK, I'm with you that this will not be on by default. As you suggest
> below, this is something that can (and will) be made an optional mode.

I personally think the default should be to protect certain names, as that will
reduce the chances of new users getting in a mess.

More experienced uses can then elect to unprotect these variables.

Dave


Robert Bradshaw

unread,
Feb 20, 2010, 9:02:11 PM2/20/10
to sage-...@googlegroups.com

I'm all for a special mode, but to do this by default would be
backwards incompatible and yet another incompatibility from Python.

- Robert

Bill Hart

unread,
Feb 20, 2010, 10:22:15 PM2/20/10
to sage-devel
For math programs you concoct, symbols such as you lay out may not
crop up, but for my work such symbols must occur.

Try to say all that w'out 'm.

On 21 Feb, 02:02, Robert Bradshaw <rober...@math.washington.edu>
wrote:

Nick Alexander

unread,
Feb 20, 2010, 10:40:02 PM2/20/10
to sage-...@googlegroups.com
> I'm all for a special mode, but to do this by default would be
> backwards incompatible and yet another incompatibility from Python.

I'm -1 for a special mode, but I am +1 for keeping the default to be
like Python. Out of curiosity, does anyone use the special mode that
transforms "a b" -> "a*b"?

Nick

Oscar Lazo

unread,
Feb 20, 2010, 11:19:33 PM2/20/10
to sage-devel
I do, but it's not available in the notebook :(

Oscar

William Stein

unread,
Feb 21, 2010, 1:48:41 AM2/21/10
to sage-...@googlegroups.com

I do. If you're typing in a bunch of formulas and working in an
"experimental mode (mood?)" it is *very* useful to be able to (1) have
variables automatically appear without predefining them, and (2) not
have to write *'s.

>
> Nick

William Stein

unread,
Feb 21, 2010, 1:49:38 AM2/21/10
to sage-...@googlegroups.com
On Sat, Feb 20, 2010 at 8:19 PM, Oscar Lazo <algebra...@gmail.com> wrote:
> I do, but it's not available in the notebook :(
>
> Oscar

I rewrote it in October so that it *does* work in the notebook now. Try it:

implicit_multiplication(True)

-- william

>
> On 20 feb, 21:40, Nick Alexander <ncalexan...@gmail.com> wrote:
>> > I'm all for a special mode, but to do this by default would be
>> > backwards incompatible and yet another incompatibility from Python.
>>
>> I'm -1 for a special mode, but I am +1 for keeping the default to be
>> like Python.  Out of curiosity, does anyone use the special mode that
>> transforms "a b" -> "a*b"?
>>
>> Nick
>

Jason Grout

unread,
Feb 23, 2010, 9:51:11 AM2/23/10
to sage-...@googlegroups.com


Same here: +1 for special mode, -1 for making this default.

Maybe we could make a "New user" checkbox in the notebook like the
"Typeset" checkbox, which turns on protected mode, automatic variable
names, and implicit multiplication?

Jason

--
Jason Grout

Simon King

unread,
Feb 23, 2010, 4:59:43 PM2/23/10
to sage-devel
Hi Jason!

On 23 Feb., 15:51, Jason Grout <jason-s...@creativetrax.com> wrote:
> Maybe we could make a "New user" checkbox in the notebook like the
> "Typeset" checkbox, which turns on protected mode, automatic variable
> names, and implicit multiplication?

But wouldn't this encourage new users to take protected mode,
automatic variable creation and implicit multiplication for granted?
Then, eventually, it would become a de-facto default for users, even
when it is not the "official" default. I wouldn't find that desirable
at all. Thus:
I am -1

Cheers,
Simon

John Cremona

unread,
Feb 23, 2010, 5:15:29 PM2/23/10
to sage-...@googlegroups.com

I agree with Simon. But if we could have some kind of general
option-setting button where these things could easily be switched on
and off (a bit like the typesetting switch) that would make them
easier to find and use.

John

> Cheers,
> Simon

Reply all
Reply to author
Forward
0 new messages