The Artima Developer Community
Sponsored Link

Python Buzz Forum
Style-insensitive names

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ian Bicking

Posts: 900
Nickname: ianb
Registered: Apr, 2003

Ian Bicking is a freelance programmer
Style-insensitive names Posted: Jan 25, 2004 6:52 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ian Bicking.
Original Post: Style-insensitive names
Feed Title: Ian Bicking
Feed URL: http://www.ianbicking.org/feeds/atom.xml
Feed Description: Thoughts on Python and Programming.
Latest Python Buzz Posts
Latest Python Buzz Posts by Ian Bicking
Latest Posts From Ian Bicking

Advertisement

An interesting feature of the XL language (found via Hans Nowak) is the idea of style-insensitive names. To quote the features:

To most non-programmers, JohnSmith, john_smith and JOHN_SMITH all denote the same person. As programmers, we unlearn this identity to make them different. When looking up a name, XL ignores case and separating underscore '_' characters (two consecutive underscores are not allowed).

// There is only one 'file' and one 'open_file' below
function OpenFile(string Name, Mode) return file
FILE F := open_file("foo.dat", "r")

On the other hand, name overloading allows you to reuse the same name for different entities when the name will not be used in the same context.

type rectangle
function Rectangle(integer X, Y, Width, Height) return rectangle
rectangle Rectangle := Rectangle(10, 10, 20, 20)

In addition, XL, like any Mozart-based language, requires a renderer, which can be used to present code to programmers with their preferred style.

Why? Style preferences cause religious reaction from many otherwise reasonable programmers. Style insensitivity allows reuse of libraries while maintaining a consistent style in your own code.

Cons: Entities that would be distinguished by case in the real world can no longer be distinguished this way. For instance, V for volume and v for speed in physics. This is common and reasonable practice.

An interesting idea, indeed. Python's lack of a naming style annoys me a great deal -- I'd be happy to use any naming style, if there were any reason to pick one over the other. Even the standard library has nothing approaching a standard naming style (there's even capitalized method names).

But there is no reason to pick one over the other. The only standard we have is CamelCase class names, and (except for the very occasional exception) method names start with lower case letters. After that all bets are off.

Anyway, style insensitivity seems like a cool way to deal with it. Maybe it would be annoying if there wasn't contextual names (like the in the rectangle example). But maybe not so bad either.

Read: Style-insensitive names

Topic: Python nit, chapter 3 Previous Topic   Next Topic Topic: Designing a card game (5)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use