help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: constants or readonly variables


From: Maynard Wright
Subject: Re: constants or readonly variables
Date: Sun, 08 Nov 2015 21:46:27 -0800
User-agent: KMail/4.13.3 (Linux/3.16.0-30-generic; KDE/4.13.3; i686; ; )

On Saturday, November 07, 2015 04:37:57 PM Nicholas Jankowski wrote:
> On Nov 7, 2015 8:53 AM, "Maynard Wright" <address@hidden> wrote:
> > On Saturday, November 07, 2015 11:51:48 AM Francesco Potortì wrote:
> > > >this is more of a style issue, but be aware that "e" in octave is a
> > > >built-in
> > > >​
> > > >octave:1> e
> > > >ans =  2.7183
> > > >
> > > >​which you have just overwritten ...
> > > >It could potentially result in some hard to debug problem.
> > > >The same goes for "i" "j" (or "pi").
> > > >I suggest to use "ee" or "ii" or "jj" var names instead.
> > > 
> > > Which makes me think of something.  What you describe is in fact an
> > > annoying trap when programming in Octave.  A useful feature would be to
> > > have the possibility to mark a variable as constant, or readonly.
> > 
> > Good advice.   When I want to use any term that might, however remotely
> > possible, create any conflict, I add an "h" in some early location that
> 
> usually
> 
> > won't change (much) the pronunciation or the meaning of the word.   If I
> 
> would
> 
> > like to use "integer, " for instance, I use "ihnteger."  Just a personal
> > attempt to keep myself out of trouble.
> 
> The i and j usage issues mainly have to do with messing up definition of
> complex numbers after using one to index a for loop.  Many people use a 1
> in front of any complex I or j  to ensure it is processed as a complex
> value ( 4+1i, or exp(1j*theta)
> 
> I don't know if that works for other predefined constant in Octave or Matlab
> 
> Nick J.


I use "1j" a lot as I work with complex variables and want to be safe about 
it.   I tried redefining "e" and then using "1e."   The redefinition works, but 
using "1e" results in a syntax error.


Maynard Wright




reply via email to

[Prev in Thread] Current Thread [Next in Thread]