Domanda

I am interested in S-expressions, but I still don't have the right idioms in mind.

Imagine a VLSI component, characterized by a name and a list of typed ports. What is preferable :

(component name (p1 float) (p2 float))

or

(component name ((p1 float) (p2 float)))

?

È stato utile?

Soluzione

The first says,

I am absolutely sure, for all time, that the component item consists of a name and 0-n ports, and nothing else.

The second states:

The component item consists of a name and a list of ports, and I might decide to add some other things later.

Altri suggerimenti

I'd personally prefer the first because it's more readable/editable, but either is possible. It depends on how complicated your sexprs are going to be and how you're going to process them.

It depends why you want S-expressions.

You can view them as a way to express textually some structured data. (In that broad sense, JSON, YAML and even XML could be similar).

Or you can view them as expressions for some interpreter which interprets them. Then you have to define that interpreter.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top