Q: how to start a module name with a lower case character?

M

Mark Watson

I am trying to write Ruby classes to model RDF, RDFS, and Owl, much
like SWCLOS does for Common Lisp:

module Rdfs
....
end

x = Rdfs::Class.new(Rdfs::Label => "label_1")

It would be nice to have a hack that would allow module names to start
with a lower case letter. Any ideas?

It would also be good to be able to alias "::" to ":" so that I could
use a syntax like:

rdfs:Label

Any ideas and references to things to read, no matter how hack-like,
will be appreciated.
 
R

Robert Klemme

I am trying to write Ruby classes to model RDF, RDFS, and Owl, much
like SWCLOS does for Common Lisp:

module Rdfs
...
end

x = Rdfs::Class.new(Rdfs::Label => "label_1")

It would be nice to have a hack that would allow module names to start
with a lower case letter. Any ideas?

You can't because module names must be constants and constants have to
start with an uppercase letter.
It would also be good to be able to alias "::" to ":" so that I could
use a syntax like:

rdfs:Label

Hm, no idea whether there is a way although Ruby seems to accept the syntax:

$ ruby -ce 'rdfs:Label'
Syntax OK

Kind regards

robert
 
P

Phrogz

Robert said:
On 25.06.2007 16:53, Mark Watson wrote: [snip]
It would also be good to be able to alias "::" to ":" so that I could
use a syntax like:

rdfs:Label

Hm, no idea whether there is a way although Ruby seems to accept the syntax:

$ ruby -ce 'rdfs:Label'
Syntax OK

FWIW, this is because Ruby interprets that as a method call with a
symbol argument, i.e. rdfs( :Label )

irb(main):002:0> rdfs:Label
NoMethodError: undefined method `rdfs' for main:Object
from (irb):2
irb(main):003:0> def rdfs( *args ) p args end
=> nil
irb(main):004:0> rdfs:Label
[:Label]

So, with predefined or dynamic prefixes, you could use that syntax as
a method that returns a specially-namespaced constant.
 
G

Gregory Brown

Hm, no idea whether there is a way although Ruby seems to accept the syntax:

$ ruby -ce 'rdfs:Label'
Syntax OK

Incase it wasn't clear what was going on in Logan's post, the reason
why that syntax is okay is because it's interpreted as rdfs:)Label)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top