[nem-en] Variables of type void.

Michal Moskal michal.moskal at gmail.com
Tue Feb 20 11:16:36 CET 2007


On 2/20/07, Vladimir Reshetnikov <v.reshetnikov at gmail.com> wrote:
> Currently Nemerle allows variables of type 'void'.
> I suggest to forbid them to avoid the following confusing case:
>
>     mutable x;
>     mutable y = x = 1; /* One may suppose, that 'y' is of type 'int' */
>
>
> I cannot see where void variables may be used, because they always
> have the same value (), so one may always use void literal if needed.

They are useful in macros -- you don't need (and sometimes you cannot)
check if given value is void in order to store it and later use it.
For example:

macro add_log(e) {
  <[ log("BEGIN"); def res = e; log("END"); res ]>
}

-- 
   Michał


More information about the devel-en mailing list