Thelop Rule

ThelopRules are used in the ThelopLanguage to help creating ThelopNames from ThelopWords. Usually ThelopNames are CamelCase names looking like Wiki LinkPatterns:
	 FileOpen SystemGetTime StrFindChr


There is no real need to follow this "rule" strictly. If we use the words Screen and Clear to form a LOP name, we can form ScreenClear, screen_clear or SCREEN_CLEAR without destroying the readability or the meaning of the words. Usually (1) is preferred, but we may choose (2) or (3) or even a mix if there is a good reason for it. This depends on the ThelopHostLanguage and the situation (e.g. Java: Long and long).


List of THELOP name formation rules:

	...(work in progress)

Additional THELOP rules for OO languages: Additional THELOP rules (mixed):

So the rule for a name is...
<noun> <verb>

Wouldn't the noun be redundant for Object Oriented methods? Sounds like LOP is intended for procedural programming languages. -- JeffGrigg

Personally I would prefer to have this redundant naming of OO instance methods but I think OO people would not like to change their habits so much. So the two rules (added above) are a compromise intended to build a bridge between procedural and OO languages. If you look at the symmetry of
	 OO: object.setProperty(prop);
	 PP: ObjectSetProperty(ob,prop);
this seems to make a lot of sense, especially if you consider the implicit passing of "this".

(actually LOP in a procedural language uses the convention ClassSetProperty( instance, property )).

LOP is about ideas, goals and principles. THELOP seeks to implement them in a way usable for any programming language. If a language has limits or very strong traditions then Thelop has to adapt to these boundary conditions. Almost every progamming language has special features, data types or built in classes that must be addressed and become part of the ThelopLanguage.

LOP and THELOP have been created to communicate and not to enforce rules.


If you want to create a grammar, why not use English as its base? Instead of using <object><verb> use <verb><object> for actions. In the example above, instead of writing ScreenClear() why not ClearScreen() or better yet ClearTheScreen().

Also, how does this apply to boolean tests? How would I define a function that determines if the screen is clear? I would again go the English route and write IsTheScreenClear(). English provides a grammar we already know. Why not use it? Of course, those of you who are not native English speakers should probably use the grammar of your native language.

Instead of using <object><verb> use <verb><object> for actions. In the example above, instead of writing ScreenClear() why not ClearScreen() or better yet ClearTheScreen().

Because we are sending a message. If you are talking to me, you don't have to preface each word intended for me with the name Robert.

 robert: Robert, sit down.
 robert: Robert, stand up.
 robert: Robert, spin around.

Instead, you can just do the following:

 robert: Sit down.

Just as you can:

 screen: Clear yourself.
 screen: Draw a square using x,y,z and the color c

This is why they are called objects. They are the object of the sentence. The object provides a context. When someone writes:

 ClearScreen( screen_handle );

They are being redundant. In OO, we say that the screen_handle should be a private implementation detail of a screen object. Because of this, we prefer to say:

 screen.clear();

Because of this, if we change to a different system that uses something other than handles to represent the device context of a screen, we are not tied to it.

-- RobertDiFalco


...why not use English... ...why not use <action><object>...

In THELOP we try to unify the approaches of procedural programming and object oriented programming. You can do this with ScreenClear() and Screen.clear(). You can't do this with ClearScreen() and Screen.clear().

According to LOP any word in a name should "mean" something. It should tell us something about what the function is doing. E.g. the word "The" in ClearTheScreen carries no additional meaning (compared to ClearScreen), so it shouldn't be added. Also: names that tell us *completely* what a function is doing tend to become long. So we have to try to keep them short and simple. So: no "The" again. See also: OccamsRazor, SmallIsBeautiful.

THELOP names work also as namespaces. This is impossible if you use names like "OpenWindow" and "OpenFile". Functions that do similar things should also be near each other in alphabetic ordering. This eases the use of API reference ("what functions do I have available for Window...") considerably. Example: look up all functions in the Win32 API that have to do with "Window".

THELOP tries hard to reduce the number of possible names by goals and rules. This gives a high chance that two programmers will choose the same name for the same purpose. Even if this is not the case: correct use of LOP guarantees that two functions with the same name - written by independent programmers - have the same signature and do the same thing.

-- HelmutLeitner

"THELOP names work also as namespaces"

Why not use a language with proper support for namespaces? I can see the need for strict naming conventions in a language such as C which does not have a good module system, but in Java or C++ you already have support for namespaces at the module level, to group related classes, and at the class/object level, to group related functions and data into a single, named concept.

"... names that tell us *completely* what a function is doing tend to become long. So we have to try to keep them short and simple."

What is wrong with long names? Isn't descriptive and readable preferable to short and terse? Why create a set of 3 letter abbreviations when there are perfectly good words that are already well known? Why not use fully descriptive names rather than a terse pidgin-language description?

You have just met one. I gave up abbreviations shortly after compilers support variable names of more than 8 characters. I also include articles (a, an, the, my) with variable names for improved readability. And I am talking about what I actually do in my own code.


"This gives a high chance that two programmers will choose the same name for the same purpose."

Why is it desirable for two different programmers to choose the same name for different functions? I would gladly accept variability in naming if in return I got descriptive names. In fact, in most languages without namespaces duplicate function names are a huge problem, not an advantage.

Who is the global naming authority which ensures no duplication of data type names? Who gets ownership of "str"? Is it a C char *, a C++ std::basic_string<char *>, a VB variant holding a BSTR, or a myriad of other possibilities? Does CloseWindow() apply to a Microsoft window, a UNIX X-Window, or a car window in an onboard micro?

Currently there is no global naming authority, except that I created THELOP and currently define and describe it. In the future there might be a Wiki community that takes this position and maintains a ThelopDictionary.

There is no need to have different words for a BASIC "String" or a Java "String" or a C "Str". Just consider "String" and "Str" as synonyms and semantically equivalent and as the default data type used for text strings.

Then, to repeat the question from above, how does LOP prevent duplicate function names? If this is about API calls, then the function names will be shared among different languages. I still fail to see the advantage of your restrictive naming scheme.

The word "Window" is used in its computer world meaning. If you need the real world meaning (which is rare), I would suggest to create a special THELOP modifier word, e.g. "RealWorld" (perhaps abbreviated to a slang word "Rw") so that one can write

     WindowOpenTitleRect(...)
     CarSetWindowRwPosition(...)
     parent=WindowRetParent(...)
     PersonSetParentRwName(...)

but up to now, there was no need to add such a word. Again there is no need to have separate words for MS or UNIX GUI windows.

And let's add WindowIP for the IP sliding window. And maybe WindowRL for the window to launch a rocket. And WindowAR for displaying a window in an architectural drawing. I thought LOP was supposed to support natural language programming. In the real world, names are reused. You can't create a context free set of universal nouns. Why try? Have you ever ported programs between MS and UNIX? How do you prevent naming collisions?
See also: LanguageOrientedProgramming, ThelopNameExamples
CategoryThelop

EditText of this page (last edited December 3, 2007) or FindPage with title or text search