[Nickle] const vs. final

Jamey Sharp jamey at minilop.net
Wed Aug 18 16:14:53 PDT 2004


Hey, I wrote some nickle code. I needed the C-like enum behavior where a
set of names gets successive integer values starting at 0, so I wrote
this function.

void enumerate(*int values...)
{
	for(int i = 0; i < dim(values); ++i)
		*(values[i]) = i;
}

I can call it like "enumerate(&(int x), &(int y));", which is nice. But
I'd like the ints that result to be constant. The error messages that
result from trying this are confusing, but I'm pretty sure they're
buggy.

# Debian nickle 2.31-1
> enumerate(&(const int a), &(const int b));
->     enumerate (&constint a, &constint b);
<stdin>:1: Attempt to assign to static variable "x.    "
->     enumerate (&constint a, &constint b);
<stdin>:1: Attempt to assign to static variable "x.    "

# Debian nickle 2.43-1
> enumerate(&(const int a), &(const int b));
->     enumerate (&constint a, &constint b);
<stdin>:1: Attempt to assign to static variable t      "
->     enumerate (&constint a, &constint b);
<stdin>:1: Attempt to assign to static variable t      "

The behavior that I want is like Java's 'final'. Assignments to
uninitialized const values should be allowed. Is there something wrong
with doing that?
-- 
Jamey Sharp <jamey at minilop.net> - http://minilop.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : /pipermail/nickle/attachments/20040818/b92caf80/attachment.pgp


More information about the Nickle mailing list