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

**URL:** <https://www.ruby-forum.com/t/q-how-to-start-a-module-name-with-a-lower-case-character/107710>\
**Category:** Ruby\
**Created:** [June 25, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/q-how-to-start-a-module-name-with-a-lower-case-character/107710 "2007-06-25T16:56:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marksbrain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6bbea6/32.png) [@marksbrain](https://www.ruby-forum.com/u/marksbrain)\
**Post date:** [June 25, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/q-how-to-start-a-module-name-with-a-lower-case-character/107710/1 "2007-06-25T16:56:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![marksbrain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6bbea6/32.png) [@marksbrain](https://www.ruby-forum.com/u/marksbrain)\
**Post date:** [June 25, 2007, 5:08pm UTC](https://www.ruby-forum.com/t/q-how-to-start-a-module-name-with-a-lower-case-character/107710/2 "2007-06-25T17:08:32Z")

</div>

On 6/25/07, Mark W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It would be nice to have a hack that would allow module names to start

I can think of two hacks, one to get lowercase module names, and one to  
get  
a single colon, but they aren’t compatible with each other:

Lowercase module name:

rdfs = Module.new do  
… code …  
end

(Note that rdfs is a local variable, with all the attendant scoping  
issues)

rdfs:Label syntax:

module Rdfs  
… code …  
end

def rdfs( name )  
Rdfs.const\_get(name)  
end

rdfs:Label # yuck

You know if you really want to make look just like the syntax you want,  
you  
can use strings. I would not recommend abusing ruby to the extent you  
would  
have to almost acheive what you want.

---

<div class="post-metadata">

**Author:** ![marksbrain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6bbea6/32.png) [@marksbrain](https://www.ruby-forum.com/u/marksbrain)\
**Post date:** [June 25, 2007, 7:32pm UTC](https://www.ruby-forum.com/t/q-how-to-start-a-module-name-with-a-lower-case-character/107710/3 "2007-06-25T19:32:13Z")

</div>

On 25.06.2007 16:53, Mark W. wrote:

> 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

---

<div class="post-metadata">

**Author:** ![marksbrain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6bbea6/32.png) [@marksbrain](https://www.ruby-forum.com/u/marksbrain)\
**Post date:** [June 25, 2007, 8:06pm UTC](https://www.ruby-forum.com/t/q-how-to-start-a-module-name-with-a-lower-case-character/107710/4 "2007-06-25T20:06:18Z")

</div>

Robert K. wrote:

> On 25.06.2007 16:53, Mark W. 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.

---

<div class="post-metadata">

**Author:** ![marksbrain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6bbea6/32.png) [@marksbrain](https://www.ruby-forum.com/u/marksbrain)\
**Post date:** [June 25, 2007, 8:08pm UTC](https://www.ruby-forum.com/t/q-how-to-start-a-module-name-with-a-lower-case-character/107710/5 "2007-06-25T20:08:18Z")

</div>

On 6/25/07, Robert K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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)
