[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Token types with constructor
From: |
Akim Demaille |
Subject: |
Re: Token types with constructor |
Date: |
Fri, 03 Sep 2004 11:27:02 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
>>> "Martin" == Martin Trautmann <address@hidden> writes:
| What is the problem with the following code in the current bison
| version:
| class Token
| {
| std::string str;
| int i;
| };
| #define YYSTYPE Token
This is unrealistic:
- There are usually many more than merely two different entities. So
you're possibly wasting way too much space.
- From the C++ point of view, it's even worse: you're calling n
different ctor and dtor for each symbol! Not to mention the cost of
the copy.
There is just no decent way to store different object types, you have
to store pointers (there are nice proposals for Variant types in
future C++es, but that's not for tomorrow). Also, introducing an
artificial common root to all the symbols often breaks the AST design,
or worse, weakens types hence type safety.
- Re: Token types with constructor, (continued)
Re: Token types with constructor, Wolfgang Wieser, 2004/09/03
Re: Token types with constructor, Hans Aberg, 2004/09/02
Re: Token types with constructor, Martin Trautmann, 2004/09/02
Re: Token types with constructor, Wolfgang Wieser, 2004/09/02
Re: Token types with constructor, Hans Aberg, 2004/09/02
Re: Token types with constructor,
Akim Demaille <=
Re: Token types with constructor, Martin Trautmann, 2004/09/09
Re: Token types with constructor, Hans Aberg, 2004/09/13