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

Allow declaring @container on @type #122

Closed
jmandel opened this issue May 17, 2012 · 7 comments
Closed

Allow declaring @container on @type #122

jmandel opened this issue May 17, 2012 · 7 comments

Comments

@jmandel
Copy link
Contributor

jmandel commented May 17, 2012

For consistent framing, I sometimes want to force an object's @type into an array. This would mean allowing a context like:

{
  "@type": {
    "@container": "@set"
  }
}

... which currently throws a 'keywords cannot be overridden' error.

@lanthaler
Copy link
Member

We discussed that several times but so far we decided to not support that. I see a number of problems with this:

  • @type gets an even more special keyword - even more special code would be needed for it
  • what if someone decides to set it to "@container": "@list"? There would be no way to use @type in compaction then which would force us to throw an exception.

Is this just be a "nice-to-have" for you or is it preventing some use cases respectively requiring an excessive amount of client code that could otherwise be elminited? As I see it, it just requires one additional if-statement in the client application.

@jmandel
Copy link
Contributor Author

jmandel commented May 17, 2012

From my perspective, allowing context to set a @container on @type
helps developers explicitly express their desired "data shape" in the
same way they can for other predicates. It's strictly (for me) about
simplifying client code by eliminating if/then logic. (But I think
that's important.)

To be clear, I'm only advocating that contexts be allowed to assign
@set (not @list). I understand there is a trade-off here between
complexity to implement the API vs. consume it... just wanted to put
in a word here from the consumer's perspective.

On Thu, May 17, 2012 at 1:16 AM, Markus Lanthaler
reply@reply.github.com
wrote:

We discussed that several times but so far we decided to not support that. I see a number of problems with this:
 - @type gets an even more special keyword - even more special code would be needed for it
 - what if someone decides to set it to "@container": "@list"? There would be no way to use @type in compaction then which would force us to throw an exception.

Is this just be a "nice-to-have" for you or is it preventing some use cases respectively requiring an excessive amount of client code that could otherwise be elminited? As I see it, it just requires one additional if-statement in the client application.


Reply to this email directly or view it on GitHub:
#122 (comment)

@lanthaler
Copy link
Member

Would a flag in the compaction algorithm be fine as well for you or does it absolutely need to go into the context?

@jmandel
Copy link
Contributor Author

jmandel commented May 18, 2012

If I could pass a flag in the options to frame() and that flag makes it
through to compact(), my needs would be well served.
On May 17, 2012 9:04 PM, "Markus Lanthaler" <
reply@reply.github.com>
wrote:

Would a flag in the compaction algorithm be fine as well for you or does
it absolutely need to go into the context?


Reply to this email directly or view it on GitHub:
#122 (comment)

@gkellogg
Copy link
Member

Turtle would allow setting a rdf:type as a list; it doesn't make sense, but the syntax allows it.

+1 to allow @container @set on @type

@lanthaler
Copy link
Member

Would it be a viable alternative to allow this just in framing and ignore it in all other algorithms?

@lanthaler
Copy link
Member

RESOLVED: Add a flag to the .compact() and frame.() algorithms that turns off optimization of arrays with single items in them to single values in the output.

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

No branches or pull requests

3 participants