David Hopwood writes:
 > Torsten Anders wrote:

 > > 
 > > Actually, when there is a variable you intent not to use (e.g. to comply
 > > some given interface), you may just call it _.
 > 
 > Erlang has a convention where variables that are intended to be unused have
 > names starting with _ (including _ itself). The compiler warns only about
 > non-use of variables that do not have a leading _. This is useful because
 > the _ acts as documentation that the variable is not used, but has very low
 > syntactic overhead.
 > 
 > I like this convention much better than unconditionally warning about unused
 > variables. In code that I write, unused variables are not infrequent, but
 > *almost* always occur only for code that is unfinished (and obviously so), or
 > for parameters that are intentionally not used by a particular implementation
 > of a function/procedure/method.
 > 

Yes, I think this would be a good idea too, it is often good
documentation to give an unused var a name.  I think Haskell does the
same. However, we have the additional issue that in Oz '_' can be used
anywhere to introduce a fresh unbound variable. So,

- Is '_X' equivalent to writing '_' or is it just a variable name that
  bypasses the unused var check (or even is it a variable that is
  introduced wthout declaration)?

  i.e., in (case Exp of _X then {F _X} end) are they different vars or
  the same?

- Can one write ..... {F _X _X} where _X is not in scope and introduce
  a fresh var?

I think _X should be a first class variable name that only bypasses
the unused var check.

- Should the compiler warn when a variable starting with underscore
  *is* used?

I am undecided, but I lean to yes.

cheers
k







_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to