From: Scott Wood <scottwood-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
To: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
Cc: "devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org"
<devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
Subject: Re: [PATCH v2] dtc: Add support for named integer constants
Date: Tue, 20 Sep 2011 12:35:29 -0500 [thread overview]
Message-ID: <4E78CEE1.3090403@freescale.com> (raw)
In-Reply-To: <20110920080409.GL29197-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
On 09/20/2011 03:04 AM, David Gibson wrote:
> So, there are basically two approaches to macro or function support.
>
> A) Functions
>
> We allow definition of functions with parameters. These are stored
> in some kind of parse tree representation in a symbol table. Instead
> of producing a more-or-less fully realised device tree as we parse, we
> produce some kind of parse tree showing the expressions and function
> calls. After parsing is complete we make another pass evaluating all
> the expressions and functions.
>
> Advantages:
> * Allows repeats / iteration to be done simply.
> * Potentially allows superior type and other error reporting
> * Jon already has a prototype in the test branch
>
> Disadvantages:
> * Requires a substantial runtime evaluation infrastructure to be
> implemented, including representation and storage of function
> definitions.
> * I don't like Jon's proposed syntax in the test branch because
> although it's C like, it's very much against the current
> declarative feel of dts. That is, it feels somewhat like a program
> that's executed to produce the device tree rather than a
> representation of the device tree itself
You could say the same thing about macros. This is just doing it at a
higher semantic level.
> Disadvantages:
> * The # used for preprocessor directives clashes with common
> property names beginning with #. In practice this can be
> disambiguated by assuming only # in column 0 is for cpp, but the
> options to make cpp behave this way are not necessarily portable.
There are other disadvantages, namely that cpp, while familiar, is not a
very good macro language:
- No recursive macro expansion ("self-referential" in cpp's terms) --
useful for iteration in the absence of explicit support
- No conditionals inside the macro body -- needed to make recursive
macros work, but also useful on their own
- Awkward handling of multi-line macro bodies -- backslashes
everywhere, and makes it difficult/awkward to fix the previous
issues with incremental extensions of the macro language
- Does not integrate well with the surrounding language's
indentation/formatting, especially if the directives need to be in
column 0
If we're going to use an existing macro language, something more like
the GNU assembler's macros would be nicer.
Another disadvantage of any approach that tries to separate macros from
the underlying language is that you can't have anything be conditional
on an expression that the macro layer doesn't understand.
-Scott
next prev parent reply other threads:[~2011-09-20 17:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-30 21:30 [PATCH v2] dtc: Add support for named integer constants Stephen Warren
[not found] ` <1314739818-13904-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-09-02 18:34 ` Stephen Warren
[not found] ` <74CDBE0F657A3D45AFBB94109FB122FF04B327A62D-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2011-09-08 13:09 ` Simon Glass
[not found] ` <CAPnjgZ0NzN510XJZ1ONAbMTS3vrrP8qCV8NYHq4_heZL+PizNg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-08 13:18 ` Simon Glass
[not found] ` <CAPnjgZ0gUvPSbVb+2+ohmDrqgYukb7+JQKY6P4C_mY0QGp83Gg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-09 1:35 ` David Gibson
[not found] ` <20110909013521.GD21002-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-09 3:27 ` Simon Glass
2011-09-08 18:32 ` Grant Likely
[not found] ` <20110908183211.GM2967-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2011-09-08 18:38 ` Simon Glass
2011-09-09 1:34 ` David Gibson
[not found] ` <20110909013433.GC21002-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-19 22:13 ` Stephen Warren
[not found] ` <74CDBE0F657A3D45AFBB94109FB122FF04B732144F-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2011-09-20 8:04 ` David Gibson
[not found] ` <20110920080409.GL29197-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-20 13:48 ` Jon Loeliger
[not found] ` <E1R60g6-0002XP-Pt-CYoMK+44s/E@public.gmane.org>
2011-09-20 17:02 ` Stephen Warren
2011-09-20 17:35 ` Scott Wood [this message]
[not found] ` <4E78CEE1.3090403-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2011-09-28 0:29 ` David Gibson
[not found] ` <20110928002942.GE5361-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-28 16:08 ` Scott Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E78CEE1.3090403@freescale.com \
--to=scottwood-kzfg59tc24xl57midrcfdg@public.gmane.org \
--cc=david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).