Case-sensitivity of identifiers: Difference between revisions

From Rosetta Code
Content added Content deleted
m (whitespace)
Line 11: Line 11:
=={{header|Euphoria}}==
=={{header|Euphoria}}==
{{works with|Euphoria 4.0.0}}
{{works with|Euphoria 4.0.0}}
<lang Euphoria>
<lang Euphoria>-- These variables are all different
-- These variables are all different
sequence dog = "Benjamin"
sequence dog = "Benjamin"
sequence Dog = "Samba"
sequence Dog = "Samba"
sequence DOG = "Bernie"
sequence DOG = "Bernie"
printf( 1, "The three dogs are named %s, %s and %s\n", {dog, Dog, DOG} )
printf( 1, "The three dogs are named %s, %s and %s\n", {dog, Dog, DOG} )</lang>

</lang>
=={{header|J}}==
=={{header|J}}==

<lang j> NB. These variables are all different
<lang j> NB. These variables are all different
dog=: 'Benjamin'
dog=: 'Benjamin'
Line 28: Line 26:


=={{header|Perl}}==
=={{header|Perl}}==
<lang perl># These variables are all different

$dog='Benjamin';
<lang perl>
$Dog='Samba';
# These variables are all different
$dog='Benjamin';
$DOG='Bernie';
print "The three dogs are named $dog, $Dog, and $DOG \n"</lang>
$Dog='Samba';
$DOG='Bernie';
print "The three dogs are named $dog, $Dog, and $DOG \n"
</lang>


=={{header|PureBasic}}==
=={{header|PureBasic}}==

Revision as of 09:37, 7 February 2011

Case-sensitivity of identifiers is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

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

Works with: Euphoria 4.0.0

<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>

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>

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>