Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Q: how to start a module name with a lower case character?

Reply
Thread Tools

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

 
 
Mark Watson
Guest
Posts: n/a
 
      06-25-2007
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.

 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      06-25-2007
On 25.06.2007 16:53, Mark Watson wrote:
> 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
 
Reply With Quote
 
 
 
 
Phrogz
Guest
Posts: n/a
 
      06-25-2007
Robert Klemme wrote:
> 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.

 
Reply With Quote
 
Gregory Brown
Guest
Posts: n/a
 
      06-25-2007
On 6/25/07, Robert Klemme <(E-Mail Removed)> wrote:

> 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)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Regular Expression to Replace UPPER Case Text with lower case text penny Perl Misc 28 03-10-2008 01:14 AM
Newbie: test array for lower case Mark Perl 3 02-14-2005 11:19 AM
lower case to upper case Janice C Programming 17 12-14-2004 02:35 PM
Regular expression weirdness with upper and lower case semovrs@concord.edu Perl 4 12-07-2004 01:35 PM



Advertisments