W3C home > Mailing lists > Public > public-rdf-comments@w3.org > February 2012

Re: Turtle language & version indicator?

From: David Robillard <d@drobilla.net>
Date: Wed, 29 Feb 2012 15:55:46 -0500
Message-ID: <1330548946.23771.33.camel@verne.drobilla.net>
To: David Booth <david@dbooth.org>
Cc: public-rdf-comments@w3.org
On Sun, 2012-02-26 at 09:32 -0500, David Booth wrote:
> On Sat, 2012-02-25 at 16:38 -0500, David Robillard wrote:
> > On Fri, 2012-02-24 at 18:33 -0500, David Booth wrote:
> > > I am wondering if turtle should have an optional language indicator, to
> > > be self-identifying -- perhaps something like the following line at the
> > > beginning of a turtle document:
> > > 
> > >   #! turtle
> [ . . . ]
> > #! is very loaded, I don't think we want to imply Turtle files are
> > executable by the shell (do we?)
> 
> I was wondering about that as well, but couldn't come up with solid
> arguments either way.  (Anyone got any?)  I guess one could argue that
> the "#!" convention primarily indicates the language of the document,
> and whether or not that language happens to be executable on some
> systems is a separate consideration.

#! runs deeper than you might think.  It is interpreted by the OS right
down to the lowest level to mean "execute this file with this program".

On most systems it actually requires a full path to the executable.  For
example, this does not work:

#!python
print 'hello'

To actually be useful we would need something like:

#!/usr/bin/env turtle

Which I think most would agree is not appropriate for baking in to the
spec.

>    I could imagine an n3 file to be
> considered as an executable, since it can contain rules.  The meaning
> might be "evaluate me and run any embedded rules to completion" (like
> "cwm --think").

This could be very nice, but because of the above I don't think it can
be conflated with a static language identifier, and it's not well
defined what it means to "run" an n3 file (e.g. there are many
parameters to cwm).

I think there are three reasonable options that allow for shebang:

1) A rule that allows for shebang use without rigidly specifying a
static format, e.g. "If the first line of a file is a comment that
contains the string 'turtle' the file can be assumed to be Turtle

2) Use the first two lines and an explicit tag, e.g. "If the first one
or two lines in a file are comments, and one of them is exactly '#lang
turtle', the file can be assumed to be Turtle

3) Use a proper directive like @lang <http://example.org/Turtle> .  Not
backwards compatible, but perhaps usefully allows for several N3-esque
languages in a file, allowing an implementation to skip sections in a
language it does not understand.  This would make it possible for a
Turtle implementation to read a TriG/N3 file by skipping any sections
with graphs and such.

There is some space to navigate between 2 and 3, e.g. a #lang comment
could also use a URI.  If we really need full backwards compatibility
but have a need for directives like this perhaps some standard scheme
for special comments (lines that start with #@ for example) could be
established.

-dr
Received on Wednesday, 29 February 2012 20:56:11 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 29 February 2012 20:56:11 GMT