Case-sensitivity of identifiers: Difference between revisions
+Java |
Added PicoLisp |
||
Line 36: | Line 36: | ||
$DOG='Bernie'; |
$DOG='Bernie'; |
||
print "The three dogs are named $dog, $Dog, and $DOG \n"</lang> |
print "The three dogs are named $dog, $Dog, and $DOG \n"</lang> |
||
=={{header|PicoLisp}}== |
|||
<lang PicoLisp>(let (dog "Benjamin" Dog "Samba" DOG "Bernie") |
|||
(prinl "The three dogs are named " dog ", " Dog " and " DOG) )</lang> |
|||
Output: |
|||
<pre>The three dogs are named Benjamin, Samba and Bernie</pre> |
|||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
Revision as of 17:26, 15 February 2011
Three dogs (Are there three dogs or one dog?) is a code snipped used to illustrate the lettercase sensitivity of the programming language. For a case sensitive language, the identifiers dog, Dog and DOG are all different and we should get the output:
The three dogs are named Benjamin, Samba and Bernie.
For a language that is lettercase insensitive, we get the following output:
There is just one dog named Bernie.
Euphoria
<lang Euphoria>-- These variables are all different sequence dog = "Benjamin" sequence Dog = "Samba" sequence DOG = "Bernie" printf( 1, "The three dogs are named %s, %s and %s\n", {dog, Dog, DOG} )</lang>
J
<lang j> NB. These variables are all different
dog=: 'Benjamin' Dog=: 'Samba' DOG=: 'Bernie' 'The three dogs are named ',dog,', ',Dog,', and ',DOG
The three dogs are named Benjamin, Samba, and Bernie </lang>
Java
<lang java>String dog = "Benjamin"; String Dog = "Samba"; //in general, identifiers that start with capital letters are class names String DOG = "Bernie"; //in general, identifiers in all caps are constants //the conventions listed in comments here are not enforced by the language System.out.println("There are three dogs named " + dog + ", " + Dog + ", and " + DOG + "'");</lang>
Perl
<lang perl># These variables are all different $dog='Benjamin'; $Dog='Samba'; $DOG='Bernie'; print "The three dogs are named $dog, $Dog, and $DOG \n"</lang>
PicoLisp
<lang PicoLisp>(let (dog "Benjamin" Dog "Samba" DOG "Bernie")
(prinl "The three dogs are named " dog ", " Dog " and " DOG) )</lang>
Output:
The three dogs are named Benjamin, Samba and Bernie
PureBasic
<lang PureBasic>dog$="Benjamin" Dog$="Samba" DOG$="Bernie" Debug "There is just one dog named "+dog$</lang>
Python
Python names are case sensitive: <lang python>>>> dog = 'Benjamin'; Dog = 'Samba'; DOG = 'Bernie' >>> print ('The three dogs are named ',dog,', ',Dog,', and ',DOG) The three dogs are named Benjamin , Samba , and Bernie >>> </lang>
Tcl
Tcl variable names are case sensitive: <lang tcl>set dog "Benjamin" set Dog "Samba" set DOG "Bernie" puts "The three dogs are named $dog, $Dog and $DOG"</lang> Which prints...
The three dogs are named Benjamin, Samba and Bernie