Variable names

Variable names

Bild des Benutzers akki

Is there a limit on variable name length?

6 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Bild des Benutzers Rama Kishan Malladi (Intel)

Hi,
We haven't set any limit. Any specific concern which we might have overlooked?

Thanks
-Rama

Bild des Benutzers akki
Quoting Rama Kishan Malladi (Intel) Hi,
We haven't set any limit. Any specific concern which we might have overlooked?

Thanks
-Rama

Just that something like:

struct Variable {
	char* id;
	...
};

Variable* v = new Variable();
v.id = new char[strlen(str) + 1];
strcpy(v.id, str);

would require 2 memory allocations as opposed to one, as in:

struct Variable {
	char id[64];
	...
};

Variable* v = new Variable();
strcpy(v.id, str);

Of course, there are work-arounds, but, since there is a limit on string length, to me, it makes sense to put a limit on identifier length as well...

Bild des Benutzers john_e_lilley

I'd prefer there to be no limit, because that forces us to be more clever about memory management, and memory management is a big part of any realistic parallel optimization effort.

Bild des Benutzers oshapovalov
Quoting Rama Kishan Malladi (Intel) Hi,
We haven't set any limit. Any specific concern which we might have overlooked?

Thanks
-Rama

It would be convenient to set limit 256, as a string.

Bild des Benutzers john_e_lilley

I've already gone through the work and made design decisions to support arbitrary-length variable names, so it would put my design at a relative disadvantage to change the spec now.

Melden Sie sich an, um einen Kommentar zu hinterlassen.