Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create generic function canonicalize-declaration-specifier #1

Open
robert-strandh opened this issue Apr 20, 2017 · 7 comments
Open

Comments

@robert-strandh
Copy link
Collaborator

robert-strandh commented Apr 20, 2017

This enhancement consists of writing a generic function named
CANONICALIZE-DECLARATION-SPECIFIER. It should take four parameters:

  • SYSTEM. An object representing the Common Lisp system.

  • DECLARATION-IDENTIFIER. A symbol that identifies what kind of
    declaration specifier to be canonicalized. Methods will have EQL
    specializers for this parameter. When the declaration specifier is a
    type specifier, the identifier will always be the symbol TYPE. No
    implicit type specifiers will ever be passed to this function.

  • DECLARATION-IDENTIFIER-CST. A CST that has DECLARATION-IDENTIFIER
    as its associated RAW data.

  • DECLARATION-DATA. A CST that has the CDR of the declaration
    specifier to be canonicalized as its associated RAW data.

It should return a list of CSTs representing canonicalized declaration
specifiers. A canonicalized declaration specifier is one of the
following:

  • (declaration name)
  • (dynamic-extent var)
  • (dynamic-extent (function fn))
  • (ftype type function-name)
  • (ignore var)
  • (ignore (function fn))
  • (ignorable var)
  • (ignorable (function fn))
  • (inline function-name)
  • (notinline function-name)
  • (optimize (quality value))
  • (special var)
  • (type typespec var)

plus any canonicalized declaration specifier that is specific to the
client system. The CST representing the CAR of each element of the
list should be that of the second argument to the function. The CST
representing the canonicalized declaration data should be taken from
the corresponding information in the DECLARATION-DATA CST.

In addition to the definition of the generic function itself, the
enhancement consists of writing default methods (with the SYSTEM
parameter being unspecialized) for all standard Common Lisp type
identifiers.

A set of tests should be written to verify that the function works
for all Common Lisp declaration identifiers.
[I initially accidentally wrote "type identifiers" instead of
"declaration identifiers". Sorry about that.]

@phoe
Copy link
Member

phoe commented Apr 20, 2017

Introduction and basic use of CSTs: http://metamodular.com/concrete-syntax-tree.pdf

@robert-strandh
Copy link
Collaborator Author

Even better, go to the Documentation directory, and type `make' for the most recent version.

@sirherrbatka
Copy link

Should we introduce another subclass for declaration specifer or just use expression-cst?

@robert-strandh
Copy link
Collaborator Author

A declaration is an expression (but not a form), and in fact, a
non-null list, so the cons-cst should be used for declarations.
At the level of a CST, the only thing that the different classes can
determine is whether the expression can be taken apart (first, rest)
or not (if it is atomic). Any interpretation beyond that is outside
the scope of CSTs, and should be done by client code such as
compilers.

@robert-strandh
Copy link
Collaborator Author

Well, what I just wrote is not quite true.

The CST library provides tools that distinguish between forms,
declarations, documentation strings etc. in certain contexts. But it
does not provide any specific representation for those different kinds
of expressions. Maybe the need for such different representations
will come up at some later point.

@Bike
Copy link
Member

Bike commented Apr 20, 2017

Not sure I understand this.

I guess information about client declarations is in the system parameter. What if an identifier is unknown? Error? Are clients expected to write methods to canonicalize their declaration specifiers or is there a default?

But I think I don't understand what this function is supposed to do, because

In addition to the definition of the generic function itself, the
enhancement consists of writing default methods (with the SYSTEM
parameter being unspecialized) for all standard Common Lisp type
identifiers.

A set of tests should be written to verify that the function works
for all Common Lisp type identifiers.

which makes no sense since earlier it says DECLARATION-IDENTIFIER will be TYPE, and obviously the DECLARATION-DATA can't really be specialized on. This in turn makes me wonder why types are picked off earlier than client declarations, but whatever. Also methods on type specifiers does not make sense since they can be lists.

@robert-strandh
Copy link
Collaborator Author

I wrote: "A set of tests should be written to verify that the function
works for all Common Lisp type identifiers", but I meant "declaration
identifiers", not "type identifiers". Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants