syntax-tree / unist

Universal Syntax Tree used by @unifiedjs
https://unifiedjs.com
875 stars 19 forks source link

Use proper naming for position/location #13

Closed wooorm closed 7 years ago

wooorm commented 7 years ago

Currently, location and position is used interchangeably, while they differ. This confusion derives from node.position, which holds a location, and a location has start and end set to a position.

I propose:

anko commented 7 years ago

To clarify: you propose changes only to terminology, not to the functional spec?

wooorm commented 7 years ago

Yes, only terms! Something like this:

 ### `Node`

 ...

 ```idl
 interface Node {
   type: string;
   data: Data?;
-  position: Location?;
+  position: Position?;
 }
 ```

 ...

-#### `Location`
+#### `Position`

-**Location** references a range consisting of two points in a [Unist
+**Position** references a range consisting of two points in a [Unist
-file][file].  **Location** consists of a `start` and `end` position.
+file][file].  **Position** consists of a `start` and `end` point.
 And, if relevant, an `indent` property.

 ...

 ```idl
-interface Location {
+interface Position {
-  start: Position;
+  start: Point;
-  end: Position;
+  end: Point;
   indent: [uint32 >= 1]?;
 }
 ```

-#### `Position`
+#### `Point`

-**Position** references a point consisting of two indices in a
+**Point** references a point consisting of two indices in a
 [Unist file][file]: `line` and `column`, set to 1-based integers.  An
 `offset` (0-based) may be used.

 ```idl
-interface Position {
+interface Point {
   line: uint32 >= 1;
   column: uint32 >= 1;
   offset: uint32 >= 0?;
 }
 ```

What do you think?

anko commented 7 years ago

I like it. :+1: The naming confused me when I first read the readme, and this would help.