ibase and obase



On 6/19/06, Stavros Macrakis <macrakis at gmail.com> wrote:

> Input in bases > 10 is occasionally useful, I agree.
> But only occasionally.

Yes, and on those rare occasions, I want to get some
useful behavior, instead of "Why doesn't this work?"

> It would be a bad idea to break longstanding, useful syntax
> such as ordinary variable names (a, b, c), floating-point numbers
> (2e3 = 2000), initial zeroes (00777 = 777) and the dot operator
> (non-commutative multiplication) (aa.bb = "."(aa,bb) ) to
> accommodate large bases.

If I tell Maxima "Treat everything from a to z as a digit"
the best I can hope for is that a, b, c, 2e3, etc become integers.
If that's not what I want, then I won't change ibase.

Common Lisp allows this same ambiguity, and somehow
it staggers ahead unimpeded.

> What's more, using global variables like ibase/obase means
> that every loadfile etc. needs to be careful.

This is beside the point -- ibase and obase already exist
and already have the potential to goof up any/every bit
of code by changing the global environment, just like any
other global variable.

> This is very occasionally useful,

Yes, so one would only change ibase if they thought it useful.

> but perhaps even better would be a syntax that explicitly
> specifies the base, so that input and output are unambiguous.

I'm not opposed to that, although I wonder what is an acceptable notation.

> Or maybe sticking with the functional solution
>
>       base("A0",12)

base(A0, 12) is OK by me (I'd rather get rid of the quote marks).
The hard part of this, at present, is persuading the input
scanner to let through stuff like 3A0 -- at present this triggers
"A is not an infix operator" or some such.
base(\3A0, 12) would work. Well, it's ugly.

FWIW
Robert Dodier