|
From: | Nicholas Jankowski |
Subject: | Re: constants or readonly variables |
Date: | Sat, 7 Nov 2015 16:37:57 -0500 |
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.
[Prev in Thread] | Current Thread | [Next in Thread] |