Contexts/namespaces naming in modules

Notices and updates
Locked
Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Contexts/namespaces naming in modules

Post by Lutz »

I am considering to title-case all contexts/namespaces names used in standard modules shipped with the source distribution and installers which are currently lower-case.

This has been discussed earlier, but as it may break existing code I am interested to hear the community about this again and before changint it.

The following prefixes would be affected:

canvas.lsp - cv -> Cv
crypto.lsp - crypto -> Crypto
postscript.lsp - ps -> Ps
stat.lsp - stat -> Stat
sqlite3.lsp -> sql3 -> Sql3
unix.lsp -> unix -> Unix
zlib.lsp -> zlib -> Zlib

The following prefixes would stay as they are:

cgi.lsp - CGI
ftp.lsp - FTP
gmp.lsp - GMP
indix.lsp - INFIX (or should it be Infix ?)
mysql.lsp - MySQL
pop3.lsp - POP3
postgres.lsp - PgSQL
xmlrpc-client.lsp - XMLRPC

Basically we would follow Cormullion's suggestion to title-case namespace names except for generally known abbreviations (Internet protocols, known trademarks, etc.). The documentation (newlisp_manual.html, CodePatterns.html) mostly follows this convention already and changes would be made where this is not the case.

Most third party modules listed here: http://www.newlisp.org/modules/ also follow this convention already, and it seems to be generally accepted programming practice.

What do you think? What would be the schedule of introduction?

Ps: variables holding contexts would stay lower-case. This way both cannot be confused when reading unknown code:

Code: Select all

(new Class 'Bar)

(define (foo cx a b c)
    (set 'cx:data (+ a b c))
)

(foo Bar 1 2 3)

Bar:data => 6
... it would then be obvious that 'cx' is a variable holding a context, not a context itself.

Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Post by Jeff »

You could always just duplicate the names for a few versions:

Code: Select all

(context 'canvas)
...
(context 'MAIN)
(new 'canvas 'Cv)
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Hi Lutz,

This is only from a visual aspect and not becoming mandatory.. right?

Because If I dislike something in particular about a programming language
then its being case sensitive.. Ieeeekksss my fingers start rejecting the keyboard already..

Norman.
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Its not mandatory, only good practice and the way modules would be shipped.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Jeff:

but 'new' would also duplicate the memory used, because everything gets copied to a second context.

There is a better method using a context variable:

Code: Select all

(context 'foo)

(define (bar x y) ..._

(context MAIN)

(set 'Foo foo)

(Foo:bar 3 4) ; will call foo:bar
This technique is also described in the canvas module. The canvas and the postsrcipt module are API compatible. When I was testing the canvas module, I just plugged in the old postscript modules for testing.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

My suggestion was for future modules. I'm voting against changes that break existing code.

m i c h a e l
Posts: 394
Joined: Wed Apr 26, 2006 3:37 am
Location: Oregon, USA
Contact:

Post by m i c h a e l »

I think what cormullion is responding to here is the reason standards committees are set up to begin with. I, too, was bitten by 10, but the bites have mostly healed now. Granted, I have no modules of code floating around to continue mauling me.

It’s the ol’ ebb-and-flow between freedom and security.

As newLISP matures, changes will naturally become less frequent and drastic. Till then, we’re riding the rough Western range, where nothing is gare-on-teed.

As to the naming change, I kind of liked the idea that module names were lowercased to set them off from classes :-) But I know Lutz struggles with his decisions about every tiny detail of newLISP, so I’ll naturally defer to him.

m i c h a e l

m35
Posts: 171
Joined: Wed Feb 14, 2007 12:54 pm
Location: Carifornia

Post by m35 »

I know there's been a lot of talk about contexts and possible identifier collisions recently. I've been wondering if we shouldn't start a more unique naming convention:

Code: Select all

(context 'org.newlisp.cv)
(context 'org.newlisp.crypto)
(context 'org.newlisp.ps)
(context 'org.newlisp.stat)
(context 'org.newlisp.sql3)
(context 'org.newlisp.unix)
(context 'org.newlisp.zlib)
Referring to these long identifiers might be annoying, but you can always make an alias.

Code: Select all

(setq Sql3 org.newlisp.sql3)
Of course this Java-like pattern is only one style. We have nearly all characters available to do whatever we want.

Locked