What this Case Sensitivity really means? - keyword

We all know there are some case sensitive languages, as well as case insensitive. Eiffel is a case insensitive one, according to the details I found. If a language is case insensitive, that means its keywords also case insensitive, right? But, in Eiffel, there is a small problem. Please have a look at the following link
http://docs.eiffel.com/book/method/eiffel-language-reserved-words#False
The above link contains the list of Eiffel keywords. Normally, if a language is case insensitive, all of the keywords are listed in lower case or uppercase in their web sites. However, in the above link, the keywords in 1.12, 1.23, etc are having cases. Which means, the keywords "True", "False", "TUPLE", "Void" etc are having both lowercase and uppercase letters.
So, does this mean Eiffel keywords are case sensitive? If the answer is No, then why they are listed such a manner?

It's just a question of style. In Eiffel, all class names are by convention written all uppercase. TUPLE is a class, so it is usually written all uppercase.
Keywords representing a value or a constant (True, False, Result, Current, Void, ...) have their first letter capitalized.
"Regular" keywords (and pretty much everything else) are all lowercase.
Eiffel is case insensitive, so you could write tuple, or Tuple, or TUPle, but it is poor style doing so. See this post for more on that matter: http://dev.eiffel.com/Style_Guidelines

Related

Delphi - create Title/Proper/Mixed Case for Strings

I have a list of approx 100,000 names I need to process. Some are business names, some are people names. Unfortunately, some are lower, some are upper, and some are mixed. I am looking for a routine to convert them to proper case. (Sometimes called Mixed or Title case). I realize I can just loop through the string and capitalize every character that starts a new word. That would be an incredibly simplistic approach. For businesses, short words should be lowercase (of, with, for, ...). For last names, if it starts with Mc, the 3rd letter should be capitalized (McDermot, McDonald, etc). Roman numerals should always be capitalized (John Smith II ), etc.
I have not been able to find any Delphi built in, or otherwise, routines. Surely this is out there. Where can I find this?
Thanks
As it was already said by others, making a fully automated routine for this is nearly impossible due to so many special variations. So leaving out the human interaction completely is almost impossible.
Now what you can do instead is to make this much easier for human to solve. How? Make a dictionary of all the name variations in Lowercase and present it to him.
Before presenting the names you can make sure that the first letter in any of the names is already capitalized.
Once all name correction has been made in dictionary you go and automatically replace all the names in original database.

Regexp for a name

I need to make sure people enter their first, middle and last names correctly for a form in Rails. So the first thought for a regular expression is:
\A[[:upper:]][[:alpha:]'-]+( [[:upper:]][[:alpha:]'-]*)*\z
That'll make sure every word in the name starts with an uppercase letter followed by a letter or hyphen or apostrophe.
My first question I guess doesn't have much to do with regular expressions, though I'm hoping there's a regular expression I can copy for this. Are letters, hyphens and apostrophes the only characters I should be checking in a name?
My second question is if it's important to make sure each name has at least 1 uppercase letter? So many people enter all lowercase names and I really want to avoid that, but is it sometimes legitimate?
Here's what I have so far that makes sure there's at least 1 uppercase letter somewhere in the name:
\A([[:alpha:]'-]+ )*[[:alpha:]'-]*[[:upper:]][[:alpha:]'-]*( [[:alpha:]'-]+)*\z
Isn't there a [:name:] bracket expression? :)
UPDATE: I added . and , to the characters allowed, surprised I didn't think of them originally. So many people must have to deal with this kind of regular expression! Nobody has any pre-made regular expressions for this sort of thing?
A good start would be to allow letters, marks, punctiation and whitespace. To allow for a given name like "María-Jose" and a last name like "van Rossum" (note the whitespace).
So that boils down to something like:
[\p{Letter}\p{Mark}\p{Punctuation}\p{Separator}]+
If you want to restrict that a bit you could have a look at classes like \p{Lowercase_Letter}, \p{Uppercase_Letter}, \p{Titlecase_Letter}, but there may be scripts that don't have casing. \p{Space_Separator} and \p{Dash_Punctuation} can narrow it down to names that I know. But names I don't...I don't know...
But before you start constructing your regex for "validating" a name. Please read this excellent piece on names by W3C. It will shake even your concepts of first, middle and last names.
For example:
In some cultures you are given a name (Björk, Osama) and an indication of who your father (or mother) was (Guðmundsdóttir, bin Mohammed). So the "first name" could be "Björk" but:
Björk wouldn’t normally expect to be called Ms. Guðmundsdóttir. Telephone directories in Iceland are sorted by given name.
But in other cultures, the first name is not given, but a family name. In "Zhāng Mànyù", "Zhāng" is the family name. And how to address her, would depend how well you know her, but again "Ms. Zhāng" would be strange.
The list of examples goes on and ends in a some 30+ links to Wikipedia for more examples.
The article does end with suggestions for field design and some pointers on what characters to allow:
Don't forget to allow people to use punctuation such as hyphens, apostrophes, etc. in names. Don't require names to be entered all in upper case – this can be difficult on a mobile device. Allow the user to enter a name with spaces , eg. to support prefixes and suffixes such as de in French, von in German, and Jnr/Jr in American names, and also because some people consider a space-separated sequence of characters to be a single name, eg. Rose Marie.
To answer your question about capital letters: in many areas of the world, names do not necessarily start with a capital letter. In Dutch for instance, you have surnames like "van der Vliet" where words like "van", "de", "den" and "der" are not capitalised. Additionally, you have special cases like "De fauw" and "Van pellicom" where an administrative error never got rectified, and the correct capitalisation is fairly illogical. Please do not make the mistake of rejecting such names.
I also know about town names in South Africa such as eThekwini, where the capital letter is not necessarily the first letter of the word. This could very well appear in surnames or given names as well.

Recursive grammar for the language of strings

I was given the following task:
Write a recursive grammar for the language of strings of one or more letters. The first letter of each string must be uppercase, and all other letters in the string must be lowercase.
After reading the chapter on grammar, and exploring some examples, this is my attempt:
<goodString> =<UpCh>|<UpCh> <ch>
<UpCh> = A|B|C...|Z
<ch> = a|b|c...|z
or maybe
<goodString> =<UpCh>|<goodString> <ch>
<UpCh> = A|B|C...|Z
<ch> = a|b|c...|z
Is this right? If not, what did I do wrong?
Right now your grammar isn't recursive. A recursive grammar would/will include at least one production that invokes itself (directly or indirectly) on the right side.
In this case, the obvious place to use that would be "an indefinite number of lower case letters". For that I'd define a lower case string (or whatever) as either nil, or a lower case string followed by a lower case letter. Then your word will be an upper case letter followed by a lower case string.
Note that for a case like this, you can define the lower case string as a character followed by a string, or as a string followed by a character. These are known as right recursive and left recursive respectively. If there's any chance you'll ever implement the grammar, you probably want to know that you want the right recursive form for a recursive descent parser, but generally prefer the left recursive form for a bottom up parser (such as many generators such as yacc, Bison, byacc, etc., produce).

What Rascal entities should be upper case?

What are the naming conventions in Rascal? It seems that modules, but not intermediate paths, tends to be upper case, also variable names. Does it make a difference? What is the convention and the rationale behind it?
We are working towards the convention that:
identifiers for functions, variable names, constructors, fields names of tuples and constructors, start with lowercase and continue with camelCase.
user-defined types such as, alias, data, syntax, lexical non-terminals, start with uppercase and continue with CamelCase.
The rationale is that in Rascal syntax definitions we currently need a syntactic difference between type names and label names to prevent ambiguity, and we chose to have one with uppercase and the other with lowercase first letters. The above convention continues in that vain for the rest of the language for the sake of consistency, but is yet to be formalized.

Is there any format convention in query strings?

I was wondering if you normally capitalise any letter in query strings, use dashes or underscores for variable names, or have any other query string naming convention. I cannot find any reference to it.
Edit: Since there seems to be no convention, are there any best practices or usual way to do it?
I don't recall actually ever seeing people use dashes in parameter names in the query string. That probably shoots it down as best practice.
I would personally avoid camel case because I don't want to get into case sensitivity/insensitivity issues.
That leaves underscores, which I find is commonly used.
There is no convention in this case at all. URLs (in .NET at least) are case insensitive anyway.

Resources