Case-sensitivity of identifiers

From Rosetta Code
Jump to: navigation, search
Task
Case-sensitivity of identifiers
You are encouraged to solve this task according to the task description, using any language you may know.

Three dogs (Are there three dogs or one dog?) is a code snippet 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.

Cf.

Contents

[edit] Ada

case insensitive

with Ada.Text_IO;
procedure Dogs is
Dog : String := "Bernie";
begin
Ada.Text_IO.Put_Line ("There is just one dog named " & DOG);
end Dogs;

Output:

There is just one dog named Bernie


[edit] ALGOL 68

Works with: ALGOL 68 version Revision 1.
Works with: ALGOL 68G version Any - tested with release algol68g-2.6.

A joke code entry... :-) ¢ but the code does actually work!

File: Case-sensitivity_of_identifiers.a68
#!/usr/bin/a68g --script #
# -*- coding: utf-8 -*- #
 
STRING dog = "Benjamin";
OP D = (INT og)STRING: "Samba";
OP DOG = (INT gy)STRING: "Bernie";
INT og=~, gy=~;
 
main:(
printf(($"The three dogs are named "g", "g" and "g"."l$, dog, Dog, DOGgy));
0
)
Output:
The three dogs are named Benjamin, Samba and Bernie.

[edit] AutoHotkey

dog := "Benjamin"
Dog := "Samba"
DOG := "Bernie"
MsgBox There is just one dog named %dOG%

[edit] AWK

BEGIN {
dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
printf "The three dogs are named %s, %s and %s.\n", dog, Dog, DOG
}

The three dogs are named Benjamin, Samba and Bernie.

[edit] BBC BASIC

      dog$ = "Benjamin"
Dog$ = "Samba"
DOG$ = "Bernie"
PRINT "The three dogs are " dog$ ", " Dog$ " and " DOG$ "."

Output:

The three dogs are Benjamin, Samba and Bernie.

[edit] bc

The only variables are 'a' through 'z'. They can only hold numbers, not strings. Some implementations allow longer names like 'dog', but only with lowercase letters. A name like 'Dog' or 'DOG' is a syntax error.

obase = 16
ibase = 16
 
/*
* Store the hexadecimal number 'BE27A312'
* in the variable 'd'.
*/
d = BE27A312
"There is just one dog named "; d
quit

There is just one dog named BE27A312

[edit] Bracmat

( Benjamin:?dog
& Samba:?Dog
& Bernie:?DOG
& out$("There are three dogs:" !dog !Dog and !DOG)
);

Output:

There are three dogs: Benjamin Samba and Bernie

[edit] Brlcad

The three dogs are drawn as spheres in this simple example:

 
opendb dogs.g y # Create a database to hold our dogs
units ft # The dogs are measured in feet
in dog.s sph 0 0 0 1 # Benjie is a little Scottie dog
in Dog.s sph 4 0 0 3 # Samba is a Labrador
in DOG.s sph 13 0 0 5 # Bernie is massive. He is a New Foundland
echo The three dogs are named Benjamin, Samba and Bernie

[edit] C

C is case sensitive; if it would be case insensitive, an error about redefinition of a variable would be raised.

#include <stdio.h>
 
static const char *dog = "Benjamin";
static const char *Dog = "Samba";
static const char *DOG = "Bernie";
 
int main()
{
printf("The three dogs are named %s, %s and %s.\n", dog, Dog, DOG);
return 0;
}

[edit] C#

C# is case sensitive

 
using System;
 
class Program
{
static void Main(string[] args)
{
string dog = "Benjamin";
string Dog = "Samba";
string DOG = "Bernie";
Console.WriteLine(string.Format("The three dogs are named {0}, {1}, and {2}.", dog, Dog, DOG));
}
}

[edit] COBOL

* Case sensitivity of identifiers
*>* Commented-out lines in the working storage
*>* are considered as invalid redefinitions
*>* of ''dog'' that can only be ambiguously
*>* referenced in the procedure body.
 
IDENTIFICATION DIVISION.
PROGRAM-ID. case-sensitivity.
DATA DIVISION.
WORKING-STORAGE SECTION.
*>* 01 dog PICTURE X(8) VALUE IS "Benjamin".
*>* 01 Dog PICTURE X(5) VALUE IS "Samba".
01 DOG PICTURE X(6) VALUE IS "Bernie".
PROCEDURE DIVISION.
DISPLAY
*>* "The three dogs are named "
*>* dog ", " Dog " and " DOG "."
"There is just one dog named " DOG "."
END-DISPLAY
STOP RUN.
END PROGRAM case-sensitivity.

[edit] CoffeeScript

 
dog="Benjamin"
Dog = "Samba"
DOG = "Bernie"
console.log "The three dogs are names #{dog}, #{Dog}, and #{DOG}."
 

output

 
> coffee foo.coffee
The three dogs are names Benjamin, Samba, and Bernie.
 

[edit] Common Lisp

CL-USER> (let* ((dog "Benjamin") (Dog "Samba") (DOG "Bernie"))
(format nil "There is just one dog named ~a." dog))
; in: LAMBDA NIL
; (LET* ((DOG "Benjamin") (DOG "Samba") (DOG "Bernie"))
; (FORMAT NIL "There is just one dog named ~a." DOG))
;
; caught STYLE-WARNING:
; The variable DOG is defined but never used.
;
; caught STYLE-WARNING:
; The variable DOG is defined but never used.
;
; compilation unit finished
; caught 2 STYLE-WARNING conditions
"There is just one dog named Bernie."

These are the style warnings from SBCL. Other implementations of Common Lisp might give different warnings.

[edit] D

import std.stdio;
 
void main() {
string dog = "Benjamin";
// identifiers that start with capital letters are type names
string Dog = "Samba";
string DOG = "Bernie";
writefln("There are three dogs named ",
dog, ", ", Dog, ", and ", DOG, "'");
}

Output:

There are three dogs named Benjamin, Samba, and Bernie'

[edit] dc

A register name has only one character, so this example uses 'd' and 'D'.

[Benjamin]sd
[Samba]sD
[The two dogs are named ]P ldP [ and ]P lDP [.
]P

The two dogs are named Benjamin and Samba.

[edit] Delphi

program CaseSensitiveIdentifiers;
 
{$APPTYPE CONSOLE}
 
var
dog: string;
begin
dog := 'Benjamin';
Dog := 'Samba';
DOG := 'Bernie';
Writeln('There is just one dog named ' + dog);
end.

Output:

There is just one dog named Bernie

[edit] DWScript

 
var dog : String;
 
dog := 'Benjamin';
Dog := 'Samba';
DOG := 'Bernie';
 
PrintLn('There is just one dog named ' + dog);

Output:

There is just one dog named Bernie

[edit] Erlang

Erlang variables are case sensitive but must start with an uppercase letter.

 
-module( case_sensitivity_of_identifiers ).
 
-export( [task/0] ).
 
task() ->
catch dog = "Benjamin", % Function will crash without catch
Dog = "Samba",
DOG = "Bernie",
io:fwrite( "The three dogs are named ~s, ~s and ~s~n", [dog, Dog, DOG] ).
 
Output:
4> case_sensitivity_of_identifiers:task().
The three dogs are named dog, Samba and Bernie

[edit] Euphoria

Works with: Euphoria version 4.0.0
-- 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} )

[edit] Fortran

Works with: Fortran version 90 and later

Fortran is case insensitive

program Example
implicit none
 
character(8) :: dog, Dog, DOG
 
dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
 
if (dog == DOG) then
write(*,*) "There is just one dog named ", dog
else
write(*,*) "The three dogs are named ", dog, Dog, " and ", DOG
end if
 
end program Example

Output:

 There is just one dog named Bernie

[edit] Frink

Frink is case-sensitive.

dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
println["There are three dogs named $dog, $Dog and $DOG"]

[edit] F#

F# is case-sensitive.

let dog = "Benjamin"
let Dog = "Samba"
let DOG = "Bernie"
printfn "There are three dogs named %s, %s and %s" dog Dog DOG

[edit] GAP

# GAP is case sensitive
ThreeDogs := function()
local dog, Dog, DOG;
dog := "Benjamin";
Dog := "Samba";
DOG := "Bernie";
if dog = DOG then
Print("There is just one dog named ", dog, "\n");
else
Print("The three dogs are named ", dog, ", ", Dog, " and ", DOG, "\n");
fi;
end;
 
ThreeDogs();
# The three dogs are named Benjamin, Samba and Bernie

[edit] Go

Go is case sensitive. Further, visibility depends on case. See the Go entry under the Scope modifiers task.

package dogs
 
import "fmt"
 
// Three variables, three different names.
// (It wouldn't compile if the compiler saw the variable names as the same.)
var dog = "Salt"
var Dog = "Pepper"
var DOG = "Mustard"
 
func PackageSees() map[*string]int {
// Print dogs visible from here.
fmt.Println("Package sees:", dog, Dog, DOG)
// Return addresses of the variables visible from here.
// The point of putting them in a map is that maps store only
// unique keys, so it will end up with three items only if
// the variables really represent different places in memory.
return map[*string]int{&dog: 1, &Dog: 1, &DOG: 1}
}
package main
 
import (
. "dogs"
"fmt"
)
 
func main() {
// with the dogs package imported, there are three dogs.
d := PackageSees()
fmt.Println("There are", len(d), "dogs.\n")
 
// Declaration of new variable dog. It lives in this package, main.
dog := "Benjamin"
d = PackageSees()
fmt.Println("Main sees: ", dog, Dog, DOG)
// Four dogs now. two of the three visible from here are the
// the same as ones in the dogs package.
d[&dog] = 1
d[&Dog] = 1
d[&DOG] = 1
fmt.Println("There are", len(d), "dogs.\n")
 
// Not a declaration, just an assigment. This assigns a new value to
// the variable Dog declared in the package. Dog is visible because
// it begins with an upper case letter.
Dog = "Samba"
// same four dogs, same three visible, one just has a new name.
d = PackageSees()
fmt.Println("Main sees: ", dog, Dog, DOG)
d[&dog] = 1
d[&Dog] = 1
d[&DOG] = 1
fmt.Println("There are", len(d), "dogs.\n")
 
// Of course you can still declare a variable if you want to. This
// declares a new variable, shadowing DOG in the package and rendering
// it inaccessable even though it begins with an upper case letter.
var DOG = "Bernie"
// five dogs now. three visible from here.
d = PackageSees()
fmt.Println("Main sees: ", dog, Dog, DOG)
d[&dog] = 1
d[&Dog] = 1
d[&DOG] = 1
fmt.Println("There are", len(d), "dogs.")
}
Output:
Package sees: Salt Pepper Mustard
There are 3 dogs.

Package sees: Salt Pepper Mustard
Main sees:    Benjamin Pepper Mustard
There are 4 dogs.

Package sees: Salt Samba Mustard
Main sees:    Benjamin Samba Mustard
There are 4 dogs.

Package sees: Salt Samba Mustard
Main sees:    Benjamin Samba Bernie
There are 5 dogs.

[edit] Groovy

Solution:

def dog = "Benjamin", Dog = "Samba", DOG = "Bernie"
println (dog == DOG ? "There is one dog named ${dog}" : "There are three dogs named ${dog}, ${Dog} and ${DOG}.")

Output:

There are three dogs named Benjamin, Samba and Bernie.

[edit] Haskell

Identifiers are case sensitive in Haskell, but must start with a lower case letter.

import Text.Printf
 
main = printf "The three dogs are named %s, %s and %s.\n" dog dOG dOg
where dog = "Benjamin"
dOG = "Samba"
dOg = "Bernie"

[edit] Icon and Unicon

The program below demonstrates the three dog task. All variants of Icon/Unicon have case sensitive variable names. But if one wasn't this would find it.

procedure main()
 
dog := "Benjamin"
Dog := "Samba"
DOG := "Bernie"
 
if dog == DOG then
write("There is just one dog named ", dog,".")
else
write("The three dogs are named ", dog, ", ", Dog, " and ", DOG, ".")
 
end

[edit] 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

[edit] 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 + "'");

[edit] JavaScript

Javascript is case sensitive.

var dog="Benjamin";
var Dog = "Samba";
var DOG = "Bernie";
document.write("The three dogs are named " + dog + ", " + Dog + ", and " + DOG + ".");

[edit] K

 
dog: "Benjamin"
Dog: "Samba"
DOG: "Bernie"
"There are three dogs named ",dog,", ",Dog," and ",DOG
"There are three dogs named Benjamin, Samba and Bernie"
 

[edit] Liberty BASIC

NB the IDE warns you that there are similar variables named dog$, Dog$ & DOG$

 
dog$ = "Benjamin"
Dog$ = "Samba"
DOG$ = "Bernie"
print "The three dogs are "; dog$; ", "; Dog$; " and "; DOG$; "."
 
end
 

The three dogs are Benjamin, Samba and Bernie.

[edit] Lua

dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
 
print( "There are three dogs named "..dog..", "..Dog.." and "..DOG.."." )
There are three dogs named Benjamin, Samba and Bernie.

[edit] Maple

> dog, Dog, DOG := "Benjamin", "Samba", "Bernie":
> if nops( { dog, Dog, DOG } ) = 3 then
> printf( "There are three dogs named %s, %s and %s.\n", dog, Dog, DOG )
> elif nops( { dog, Dog, DOG } ) = 2 then
> printf( "WTF? There are two dogs named %s and %s.\n", op( { dog, Dog, DOG } ) )
> else
> printf( "There is one dog named %s.\n", dog )
> end if:
There are three dogs named Benjamin, Samba and Bernie.

[edit] Mathematica

dog = "Benjamin"; Dog = "Samba"; DOG = "Bernie";
"The three dogs are named "<> dog <>", "<> Dog <>" and "<> DOG
 
-> "The three dogs are named Benjamin, Samba and Bernie"

[edit] MATLAB / Octave

  dog = 'Benjamin';
Dog = 'Samba';
DOG = 'Bernie';
 
printf('There are three dogs %s, %s, %s.\n',dog, Dog, DOG);

Output

  There are three dogs Benjamin, Samba, Bernie.  

[edit] Maxima

/* Maxima is case sensitive */
a: 1$
A: 2$
 
is(a = A);
false

[edit] Modula-2

MODULE  dog;
 
IMPORT InOut;
 
TYPE String = ARRAY [0..31] OF CHAR;
 
VAR dog, Dog, DOG : String;
 
(* No compiler error, so the rest is simple *)
 
BEGIN
InOut.WriteString ("Three happy dogs.");
InOut.WriteLn
END dog.

[edit] Nemerle

def dog = "Benjamin";
def Dog = "Samba";
def DOG = "Bernie";
WriteLine($"The three dogs are named $dog, $Dog, and $DOG");

[edit] NetRexx

NetRexx is not case sensitive:

/* NetRexx */
options replace format comments java crossref symbols nobinary
 
dog = "Benjamin";
Dog = "Samba";
DOG = "Bernie";
 
if dog == Dog & Dog == DOG & dog == DOG then do
say 'There is just one dog named' dog'.'
end
else do
say 'The three dogs are named' dog',' Dog 'and' DOG'.'
end
 
return
 

Output:

There is just one dog named Bernie.

[edit] Nimrod

var dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
echo("There is just one dog named " & doG)

[edit] OCaml

Identifiers in OCaml are lettercase sensitive, but the first letter has to be lowercase.

let () =
let dog = "Benjamin" in
let dOG = "Samba" in
let dOg = "Bernie" in
Printf.printf "The three dogs are named %s, %s and %s.\n" dog dOG dOg

[edit] PARI/GP

dog="Benjamin";
Dog="Samba";
DOG="Bernie";
printf("The three dogs are named %s, %s, and %s.", dog, Dog, DOG)

[edit] Pascal

See Delphi

[edit] Perl

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

[edit] Perl 6

my $dog = 'Benjamin';
my $Dog = 'Samba';
my $DOG = 'Bernie';
say "The three dogs are named $dog, $Dog, and $DOG."

The only place that Perl�pays any attention to the case of identifiers is that, for certain error messages, it will guess that an identifier starting lowercase is probably a function name, while one starting uppercase is probably a type or constant name. But this case distinction is merely a convention in Perl, not mandatory:

constant dog = 'Benjamin';
sub Dog() { 'Samba' }
my &DOG = { 'Bernie' }
say "The three dogs are named {dog}, {Dog}, and {DOG}."

[edit] PicoLisp

(let (dog "Benjamin"  Dog "Samba"  DOG "Bernie")
(prinl "The three dogs are named " dog ", " Dog " and " DOG) )

Output:

The three dogs are named Benjamin, Samba and Bernie

[edit] PL/I

*process or(!) source xref attributes macro options;
/*********************************************************************
* Program to show that PL/I is case-insensitive
* 28.05.2013 Walter Pachl
*********************************************************************/

case: proc options(main);
Dcl dog Char(20) Var;
dog = "Benjamin";
Dog = "Samba";
DOG = "Bernie";
Put Edit(dog,Dog,DOG)(Skip,3(a,x(1)));
End;

Output

Bernie Bernie Berni

[edit] Prolog

In Prolog, the initial of a variable must be a uppercase letter. So the task can't be completed but we can write this code :

three_dogs :-
DoG = 'Benjamin',
Dog = 'Samba',
DOG = 'Bernie',
format('The three dogs are named ~w, ~w and ~w.~n', [DoG, Dog, DOG]).
 

The output is :

?- three_dogs.
The three dogs are named Benjamin, Samba and Bernie.
true.

[edit] PureBasic

dog$="Benjamin"
Dog$="Samba"
DOG$="Bernie"
Debug "There is just one dog named "+dog$

[edit] Python

Python names are case sensitive:

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

[edit] R

dog <- 'Benjamin'
Dog <- 'Samba'
DOG <- 'Bernie'
 
# Having fun with cats and dogs
cat('The three dogs are named ')
cat(dog)
cat(', ')
cat(Dog)
cat(' and ')
cat(DOG)
cat('.\n')
# In one line it would be:
# cat('The three dogs are named ', dog, ', ', Dog, ' and ', DOG, '.\n', sep = '')

Output:

The three dogs are named Benjamin, Samba and Bernie.

[edit] Racket

The default setting for the Racket reader is to be case sensitive:

 
#lang racket
(define dog "Benjamin")
(define Dog "Samba")
(define DOG "Bernie")
 
(if (equal? dog DOG)
(displayln (~a "There is one dog named " DOG "."))
(displayln (~a "The three dogs are named " dog ", " Dog ", and, " DOG ".")))
 

Output:

The three dogs are named Benjamin, Samba, and, Bernie.

If you need case insensitive identifiers, then use #ci to turn on case insensitivity:

 
#lang racket
#ci(module dogs racket
(define dog "Benjamin")
(set! Dog "Samba")
(set! DOG "Bernie")
(if (equal? dog DOG)
(displayln (~a "There is one dog named " DOG "."))
(displayln (~a "The three dogs are named " dog ", " Dog ", and, " DOG "."))))
(require 'dogs)
 

Output:

There is one dog named Bernie.

[edit] Retro

Retro is case sensitive.

: dog  ( -$ )  "Benjamin" ;
: Dog ( -$ ) "Samba" ;
: DOG ( -$ ) "Bernie" ;
 
DOG Dog dog "The three dogs are named %s, %s, and %s.\n" puts

[edit] REXX

Normally, the REXX language is case insensitive (with respect to language and variables).
But lower/upper/mixed variable names can be handled if you wish.

/*demonstrate case insensitive REXX variable names. (for the most part).*/
dog = 'Benjamin'
Dog = 'Samba'
DOG = 'Bernie'
 
say copies('-',20) /*show a sep for visual clarity. */
say 'dog=' dog
say 'Dog=' Dog
say 'DOG=' DOG
say copies('-',20) /*show a sep for visual clarity. */
say
 
x='dog'; dogname.x='Benjamin'
x='Dog'; dogname.x='Samba'
x='DOG'; dogname.x='Bernie'
 
say copies('=',20) /*show a sep for visual clarity. */
_='dog'; say 'dog=' dogname._
_='Dog'; say 'Dog=' dogname._
_='DOG'; say 'DOG=' dogname._
say copies('=',20) /*show a sep for visual clarity. */
/*stick a fork in it, we're done.*/

output

--------------------
dog= Bernie
Dog= Bernie
DOG= Bernie
--------------------

====================
dog= Benjamin
Dog= Samba
DOG= Bernie
====================

[edit] Ruby

Ruby gives a special meaning to the first letter of a name. A lowercase letter starts a local variable. An uppercase letter starts a constant. So dog is a local variable, but Dog and DOG are constants. To adapt this task to Ruby, I added dOg and doG so that I have more than one local variable.

module FiveDogs
dog = "Benjamin"
dOg = "Dogley"
doG = "Fido"
Dog = "Samba" # this constant is FiveDogs::Dog
DOG = "Bernie" # this constant is FiveDogs::DOG
 
names = [dog, dOg, doG, Dog, DOG]
names.uniq!
puts "There are %d dogs named %s." % [names.length, names.join(", ")]
puts
puts "The local variables are %s." % local_variables.join(", ")
puts "The constants are %s." % constants.join(", ")
end
Output:
There are 5 dogs named Benjamin, Dogley, Fido, Samba, Bernie.

The local variables are dog, dOg, doG, names.
The constants are Dog, DOG.

[edit] Run BASIC

 
dog$ = "Benjamin"
doG$ = "Smokey"
Dog$ = "Samba"
DOG$ = "Bernie"
print "The 4 dogs are "; dog$; ", "; doG$; ", "; Dog$; " and "; DOG$; "."
 

[edit] Sather

Though by convention Sather uses all uppercase letters for class names, a variable can be all uppercase.

class MAIN is
main is
dog ::= "Benjamin";
Dog ::= "Samba";
DOG ::= "Bernie";
#OUT + #FMT("The three dogs are %s, %s and %s\n",
dog, Dog, DOG);
end;
end;

Outputs:

The three dogs are Benjamin, Samba and Bernie

[edit] Scala

val dog = "Benjamin"
val Dog = "Samba"
val DOG = "Bernie"
println("There are three dogs named " + dog + ", " + Dog + ", and " + DOG + ".")

Output:

There are three dogs named Benjamin, Samba, and Bernie.

[edit] Scheme

Output may differ depending on implementation.

(define dog "Benjamin")
(define Dog "Samba")
(define DOG "Bernie")
 
(if (eq? dog DOG)
(begin (display "There is one dog named ")
(display DOG)
(display ".")
(newline))
(begin (display "The three dogs are named ")
(display dog) (display ", ")
(display Dog) (display " and ")
(display DOG)
(display ".")
(newline)))

[edit] Seed7

$ include "seed7_05.s7i";
 
const string: dog is "Benjamin";
const string: Dog is "Samba";
const string: DOG is "Bernie";
 
const proc: main is func
begin
writeln("The three dogs are named " <& dog <& ", " <& Dog <& " and " <& DOG <& ".");
end func;

[edit] Smalltalk

Works with: GNU Smalltalk

Smalltalk's symbols are case sensitive.

|dog Dog DOG|
dog := 'Benjamin'.
Dog := 'Samba'.
DOG := 'Bernie'.
( 'The three dogs are named %1, %2 and %3' %
{ dog . Dog . DOG } ) displayNl.

Outputs:

The three dogs are named Benjamin, Samba and Bernie

[edit] Tcl

Tcl variable names are case sensitive:

set dog "Benjamin"
set Dog "Samba"
set DOG "Bernie"
puts "The three dogs are named $dog, $Dog and $DOG"

Which prints...

The three dogs are named Benjamin, Samba and Bernie

[edit] UNIX Shell

dog="Benjamin"
Dog="Samba"
DOG="Bernie"
echo "The three dogs are named $dog, $Dog and $DOG."

The three dogs are named Benjamin, Samba and Bernie.

[edit] XPL0

XPL0 is normally case-insensitive, so there is really just one dog named Bernie. However, it has a command-line switch (/c) that turns case sensitivity on. All names must start with a capital letter (or an underline, so they can't clash with command words such as 'for'). Thus "dog" cannot be used as a name, but Dog, DOG and DoG (and For) can. The intent of the command-line switch (/c) is to detect inconsistent capitalizing of names such as Ascii and ASCII or CpuReg and CPUReg.

[edit] ZX Spectrum Basic

10 LET D$="Benjamin"
20 PRINT "There is just one dog named ";d$
Personal tools
Namespaces

Variants
Actions
Community
Explore
Misc
Toolbox