Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional direction for literals #175

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

rubensworks
Copy link
Member

As mentioned in #172, RDF 1.2 is scheduled to introduce the base direction concept for literals.

This PR proposes a backwards-compatible addition to the data model spec to handle this addition in RDF.

The literal interface change is quite straightforward, I don't expect much discussion on this.

The data factory on the other hand might deserve some discussion. I went for extending the types of the second optional argument of the literal() method. An alternative might have been to add a third optional argument, but I didn't go for that in this PR due to the possibility of defining a direction in combination with a datatype (which is illegal according to the RDF 1.2 spec).

@rubensworks rubensworks requested a review from a team as a code owner October 25, 2023 10:48
Copy link
Member

@bergos bergos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we define that direction must be falsy instead of undefined for other kinds of literals? That would allow aligning direction to language with an empty string and still be backward compatible.

index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
@rubensworks
Copy link
Member Author

Can we define that direction must be falsy instead of undefined for other kinds of literals? That would allow aligning direction to language with an empty string and still be backward compatible.

Yes, agreed, that makes sense :-)

Co-authored-by: Thomas Bergwinkl <[email protected]>
Copy link
Member

@bergos bergos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rubensworks
Copy link
Member Author

Will merge this as soon as rdfjs/types#38 is merged (on hold now).

@rubensworks rubensworks merged commit 88e7d91 into rdfjs:master Jan 7, 2025
@bergos
Copy link
Member

bergos commented Jan 7, 2025

Maybe a more detailed description is required if it's unclear why an empty string is allowed:

We had a longer discussion about whether the language property should be null or empty string for non-language literals and decided to go with the empty string, so it's possible to call .toUpperCase() or slice it, even if no language was set.

Aligning the direction property with the language property without having a breaking change required to allow undefined. Otherwise, I would have proposed to skip allowing undefined.

Now we have the optional chaining operator in JavaScript, and that would be a good reason to use undefined or null instead of an empty string. But as long as we don't have a strong need for a breaking change, I would try to keep it consistent. That also means a factory that supports direction should an empty string instead of null or undefined.

@rubensworks I can create a proposal if you agree to update the description.

@rubensworks
Copy link
Member Author

@bergos Sounds good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants