S-expression idioms

243 views Asked by At

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)))

?

3

There are 3 answers

2
bmargulies On BEST ANSWER

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.

0
Fred Foo On

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.

0
Basile Starynkevitch On

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.