[Top][All Lists]

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

Re: [PATCH 11/12] libpoke: Add `format`

From: Mohammad-Reza Nabipoor
Subject: Re: [PATCH 11/12] libpoke: Add `format`
Date: Fri, 28 May 2021 01:19:37 +0430

On Thu, May 27, 2021 at 10:22:08PM +0200, Jose E. Marchesi wrote:
> > For sure the current patch introduces code duplication for all phases
> > except the codegen phase (it is just literal copy of the printing code
> > with s/print/format).
> >
> > I decided to postpone the unification of the two nodes, because maybe
> > there's a chance of getting ride of `print` by using lazy-strings and
> > `format`.
> Well, precisely: if we unify the AST nodes now, into something that can
> accomodate both PRINT and FORMAT, then it will be just a matter of
> renaming it when it is time for PRINT to go away :)
> There is a detail however: print statements are... statements, and
> therefore PKL_AST_PRINT_STMT lays between PKL_AST_FIRST_STMT and
> On the other side, `format' is an expression that returns a value, not a
> statement.
> To resolve this, we could have two AST node types, still sharing the
> implementation:
>    - Contains all the attributes like fmt, types, etc.
>     - Contains a PKL_AST_FORMAT.
> That way, we will still need phase handlers for PKL_AST_FORMAT.  But the
> real work can then be in functions in pkl-ast.c, used by both

I agree.
You are right.

> >
> > The only part that requires reviewing is the codegen part.
> >
> > Should I unify the AST node in this patch, or I can do it in a subsequent
> > patch?
> I would really like to avoid all that code replication, even if it is
> temporary.

OK. I'll re-write this patch and will send it later.
And it'd be nice if you review the code generation part, so I can use
your feedback in the new patch.


reply via email to

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