tag -> label; slot -> field
This commit is contained in:
parent
17368c8961
commit
c7bae6eff8
16
TUTORIAL.org
16
TUTORIAL.org
|
@ -192,15 +192,15 @@ sorting needs to occur), but is still quite fast in general.
|
||||||
|
|
||||||
Finally, there is one more type that Preserves provides... but in a
|
Finally, there is one more type that Preserves provides... but in a
|
||||||
sense, it's a meta-type.
|
sense, it's a meta-type.
|
||||||
=Record= objects have a tag and a series of arguments (or "slots").
|
=Record= objects have a label and a series of arguments (or "fields").
|
||||||
For example, we can make a =Date= record:
|
For example, we can make a =Date= record:
|
||||||
|
|
||||||
#+BEGIN_SRC preserves
|
#+BEGIN_SRC preserves
|
||||||
<Date 2019 8 15>
|
<Date 2019 8 15>
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
In this example, the =Date= tag is a symbol; 2019, 8, and 15 are the
|
In this example, the =Date= label is a symbol; 2019, 8, and 15 are the
|
||||||
year, month, and date slots respectively.
|
year, month, and day fields respectively.
|
||||||
|
|
||||||
Why do we care about this?
|
Why do we care about this?
|
||||||
We could instead just decide to encode our date data in a string,
|
We could instead just decide to encode our date data in a string,
|
||||||
|
@ -258,17 +258,17 @@ We can make as many Record types as our program need, though it is up
|
||||||
to our program to make sense of what these mean.
|
to our program to make sense of what these mean.
|
||||||
Since Preserves does not specify the =Date= itself, both the program
|
Since Preserves does not specify the =Date= itself, both the program
|
||||||
(or person) writing the Preserves document and the program reading it
|
(or person) writing the Preserves document and the program reading it
|
||||||
need to have a mutual understanding of how many slots it has and what
|
need to have a mutual understanding of how many fields it has and what
|
||||||
the meaning the tag signifies for it to be of use.
|
the meaning the label signifies for it to be of use.
|
||||||
|
|
||||||
Still, there are plenty of interesting tags we can define.
|
Still, there are plenty of interesting labels we can define.
|
||||||
Here is one for an "iri", a hyperlink:
|
Here is one for an "iri", a hyperlink:
|
||||||
|
|
||||||
#+BEGIN_SRC preserves
|
#+BEGIN_SRC preserves
|
||||||
<iri "https://dustycloud.org/blog/">
|
<iri "https://dustycloud.org/blog/">
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
That's nice enough, but here's another interesting detail... tags on
|
That's nice enough, but here's another interesting detail... labels on
|
||||||
Records are usually symbols but aren't necessarily so.
|
Records are usually symbols but aren't necessarily so.
|
||||||
They can also be strings or numbers or even dictionaries.
|
They can also be strings or numbers or even dictionaries.
|
||||||
And very interestingly, they can also be other records:
|
And very interestingly, they can also be other records:
|
||||||
|
@ -280,7 +280,7 @@ And very interestingly, they can also be other records:
|
||||||
"content": "Say, did you finish reading that book I lent you?"}>
|
"content": "Say, did you finish reading that book I lent you?"}>
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
Do you see it? This Record's tag is... an iri Record!
|
Do you see it? This Record's label is... an =iri= Record!
|
||||||
The link here points to a more precise term saying that "this is a
|
The link here points to a more precise term saying that "this is a
|
||||||
note meant to be sent around in social networks".
|
note meant to be sent around in social networks".
|
||||||
It is considerably more precise than just using the string or symbol
|
It is considerably more precise than just using the string or symbol
|
||||||
|
|
Loading…
Reference in New Issue