bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proposal: simplify prologue alternatives into %code


From: Hans Aberg
Subject: Re: proposal: simplify prologue alternatives into %code
Date: Tue, 9 Jan 2007 15:49:57 +0100

On 9 Jan 2007, at 12:21, Paolo Bonzini wrote:

You can set up the skeleton like this:

%define "cast" "dynamic_cast"
%define "cast" "static_cast"
%define "cast" "" (or default) -> union

...

In the C++ class polymorphy variations, I had to write something like
  dynamic_cast<type>(*$k.data())
  static_cast<type>(*$k.data())

... if you are ok with

dynamic_cast<type>(*$k)

that is, instead of

struct container {
  top_class *member;
  top_class *data () { return member; }
}

you have to write this:

struct container {
  top_class *member;
  top_class &operator *() { return *member; }
}

One reason against making this the required method of implementation, is that one may end up with a polymorphic class library, which uses its own way of extracting the objects.

  Hans Aberg






reply via email to

[Prev in Thread] Current Thread [Next in Thread]