DMD as a library - recap, next steps
Jacob Carlborg
doob at me.com
Wed Jun 17 08:33:34 UTC 2020
On 2020-06-17 06:58, RazvanN wrote:
> Would it have been easier if you had the ability override certain
> portions of the semantic analysis?
Yes, definitely.
> What we are trying to push forward
> now is the ability to extend the semantic visitor and override/extend
> functionality as you wish, however, since some nodes have a lot of code
> that does semantic on them (CallExp ~1000 lines of code) you would have
> to copy paste a lot of code and modify only what interests you.
> The advantage is that you perform semantic only once.
If it's possible to design the interface so it's possible to add a
customization points both before and after the original semantic
implementation and give access it the original implementation it would
be a good start. That would suffice for my needs in the current tool.
Inheritance is a good example of this:
class Foo
{
void foo() {}
}
class Bar : Foo
{
override foo()
{
// new code
super.foo(); // call original implementation
// new code
}
}
The API doesn't need to be inheritance but it's a good example that
shows that is possible to add new code both before and after the
original implementation. And, you don't need to invoke the original
implementation at all if you don't want to.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list