Turtle shorthand syntax is like filling out a contact form where you avoid rewriting the same person's name over and over.
Imagine a teacher writing notes about Alice on a classroom whiteboard.
Instead of writing:
Alice is a student.
Alice likes pizza.
Alice knows Bob.
Alice knows Carol.
the teacher naturally compresses it into:
Alice:
- is a student
- likes pizza
- knows Bob and Carol
That is exactly what Turtle's ; and , operators do.
The Whiteboard Analogy
| Turtle Syntax | Meaning | Real-World Analogy |
|---|
; | Same subject, new predicate | Continue describing the same person |
, | Same subject and predicate, new object | List multiple items for the same relationship |
Example
:Alice a foaf:Person ;
foaf:name "Alice" ;
:knows :Bob, :Carol .
This expands internally into:
:Alice a foaf:Person .
:Alice foaf:name "Alice" .
:Alice :knows :Bob .
:Alice :knows :Carol .
Mental Model
Think of Turtle syntax like natural note-taking.
The subject (:Alice) acts like the title of a sticky note.
Every semicolon means:
“Still talking about Alice, but now describing something else.”
Every comma means:
“Still talking about the same relationship, but adding more items.”
Why This Matters
The shortcuts:
- reduce repetition
- improve readability
- make RDF authoring faster
- keep graphs visually compact
But importantly:
The graph itself does NOT change.
The parser expands the shorthand into the exact same triples.
Key Insight
; and , are purely syntactic sugar.
They make Turtle easier for humans to write and read, while the RDF engine still sees the same underlying graph structure.