Case-sensitivity of identifiers: Difference between revisions

Add Zig example
(Case-sensitivity of identifiers en Yabasic)
(Add Zig example)
 
(35 intermediate revisions by 19 users not shown)
Line 14:
* [[Unicode variable names]]
<br><br>
 
=={{header|11l}}==
11l identifiers are case sensitive.
<langsyntaxhighlight lang="11l">V dog = ‘Benjamin’
V Dog = ‘Samba’
V DOG = ‘Bernie’
print(‘The three dogs are named ’dog‘, ’Dog‘ and ’DOG‘.’)</langsyntaxhighlight>
=={{header|Action!}}==
<syntaxhighlight lang="action!">PROC Main()
CHAR ARRAY dog="Bernie"
 
PrintF("There is just one dog named %S.",dog)
RETURN</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Case-sensitivity_of_identifiers.png Screenshot from Atari 8-bit computer]
<pre>
There is just one dog named Bernie.
</pre>
=={{header|Ada}}==
case insensitive
<langsyntaxhighlight Adalang="ada">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;</langsyntaxhighlight>
 
Output:
<pre>There is just one dog named Bernie</pre>
 
=={{header|Agena}}==
Translation of Algol W. Agena is case sensitive, as this example demonstrates. Tested with Agena 2.9.5 Win32
<langsyntaxhighlight lang="agena">scope
local dog := "Benjamin";
scope
Line 48 ⟶ 56:
epocs
epocs
epocs</langsyntaxhighlight>
{{out}}
<pre>
The three dogs are named: Benjamin, Samba and Bernie
</pre>
 
=={{header|Aime}}==
<langsyntaxhighlight lang="aime">text dog, Dog, DOG;
 
dog = "Benjamin";
Line 61 ⟶ 68:
DOG = "Bernie";
 
o_form("The three dogs are named ~, ~ and ~.\n", dog, Dog, DOG);</langsyntaxhighlight>
 
=={{header|ALGOL 68}}==
{{works with|ALGOL 68|Revision 1.}}
Line 68 ⟶ 74:
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - due to extensive use of '''format'''[ted] ''transput''.}}
A joke code entry... :-) ¢ but the code does actually work!
'''File: Case-sensitivity_of_identifiers.a68'''<langsyntaxhighlight lang="algol68">#!/usr/bin/a68g --script #
# -*- coding: utf-8 -*- #
 
Line 79 ⟶ 85:
printf(($"The three dogs are named "g", "g" and "g"."l$, dog, Dog, DOGgy));
0
)</langsyntaxhighlight>'''Output:'''
<pre>
The three dogs are named Benjamin, Samba and Bernie.
Line 91 ⟶ 97:
<br>
However, depending on the "stropping" convention used and the implementation, Algol 68 can be case-sensitive. Rutgers ALGOL 68 uses quote stropping and allows both upper and lower case in identifiers and bold words. The standard bold words must be in lower-case.
<langsyntaxhighlight lang="algol68">'begin'
'string' dog = "Benjamin";
'begin'
Line 103 ⟶ 109:
'end'
'end'
'end'</langsyntaxhighlight>
 
{{out}}
Line 109 ⟶ 115:
The three dogs are named: Benjamin, Samba and Bernie
</pre>
 
=={{header|ALGOL W}}==
Algol W identifiers are not case-sensitive but variable names in inner blocks can be the same as those in outer blocks...
<langsyntaxhighlight lang="algolw">begin
string(8) dog;
dog := "Benjamin";
Line 127 ⟶ 132:
end
end
end.</langsyntaxhighlight>
{{out}}
<pre>
There is just one dog named: Bernie
</pre>
 
=={{header|APL}}==
<langsyntaxhighlight lang="apl"> DOG←'Benjamin'
Dog←'Samba'
dog←'Bernie'
'The three dogs are named ',DOG,', ',Dog,', and ',dog
The three dogs are named Benjamin, Samba, and Bernie</langsyntaxhighlight>
 
=={{header|AppleScript}}==
AppleScript labels are case insensitive, every instance of a particular label within a script document compiling to the same case as the first instance. It's possible to use vertical bars — normally used to distinguish labels from identical language or library keywords — to give the same label different cases within a script, but there's little point in doing so as it's still the same label.
 
<syntaxhighlight lang="applescript">set {dog, |Dog|, |DOG|} to {"Benjamin", "Samba", "Bernie"}
 
if (dog = |Dog|) then
if (dog = |DOG|) then return "There is just one dog named " & dog & "."
return "There are two dogs named " & dog & " and " & |DOG| & "."
else if (dog = |DOG|) then
return "There are two dogs named " & dog & " and " & |Dog| & "."
end if
return "The three dogs are named " & dog & ", " & |Dog| & ", and " & |DOG| & "."</syntaxhighlight>
 
{{output}}
<syntaxhighlight lang="applescript">"There is just one dog named Bernie."</syntaxhighlight>
 
=={{header|Arturo}}==
 
<langsyntaxhighlight lang="rebol">dog: "Benjamin"
Dog: "Samba"
DOG: "Bernie"
Line 148 ⟶ 168:
dogs: @[dog Dog DOG]
 
print ["The" size dogs "dog(s) are named" join.with:", " dogs]</langsyntaxhighlight>
 
{{out}}
 
<pre>The 3 dog(s) are named Benjamin, Samba, Bernie</pre>
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight AutoHotkeylang="autohotkey">dog := "Benjamin"
Dog := "Samba"
DOG := "Bernie"
MsgBox There is just one dog named %dOG%</langsyntaxhighlight>
 
=={{header|AWK}}==
<langsyntaxhighlight lang="awk">BEGIN {
dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
printf "The three dogs are named %s, %s and %s.\n", dog, Dog, DOG
}</langsyntaxhighlight>
 
The three dogs are named Benjamin, Samba and Bernie.
 
=={{header|BASIC}}==
==={{header|Applesoft BASIC}}===
Applesoft BASIC is case-insensitive. Applesoft BASIC keyword tokens and variable names get converted to upper case in programs. Only the first two characters of variable names are significant.
<syntaxhighlight lang="basic">dog$ = "Benjamin":Dog$ = "Samba":DOG$ = "Bernie":III = 254 * (DOG$ = dog$ AND Dog$ = DOG$) + 1: PRINT MID$ ("There is just one dog",256 - III) MID$ ("The three dogs are",III)" named " MID$ (dog$ + ", " + Dog$ + " and ",III)DOG$"."</syntaxhighlight>
{{out}}
<pre>There is just one dog named Bernie.</pre>
The Apple II and Apple II plus will convert all input characters to upper case.
<pre>THERE IS JUST ONE DOG NAMED BERNIE.</pre>
 
==={{header|BASIC256}}===
BASIC256 is case-insensitive
<syntaxhighlight lang="basic256">dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
print "There is just one dog, named "; dog
end</syntaxhighlight>
{{out}}
<pre>There is just one dog, named Bernie</pre>
 
==={{header|BBC BASIC}}===
<syntaxhighlight lang="bbcbasic"> dog$ = "Benjamin"
Dog$ = "Samba"
DOG$ = "Bernie"
PRINT "The three dogs are " dog$ ", " Dog$ " and " DOG$ "."</syntaxhighlight>
{{out}}
<pre>The three dogs are Benjamin, Samba and Bernie.</pre>
 
==={{header|Chipmunk Basic}}===
Chipmunk Basic is case-insensitive
<syntaxhighlight lang="qbasic">10 dog$ = "Benjamin"
20 dog$ = "Smokey"
30 dog$ = "Samba"
40 dog$ = "Bernie"
50 print "There is just one dog, named ";dog$</syntaxhighlight>
{{out}}
<pre>There is just one dog, named Bernie</pre>
 
==={{header|FreeBASIC}}===
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
' FreeBASIC is case-insensitive
Dim dog As String
dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
Print "There is just one dog, named "; dog
Sleep</syntaxhighlight>
{{out}}
<pre>There is just one dog, named Bernie</pre>
 
==={{header|FutureBasic}}===
FB is lettercase-insensitive and throws an error with variables or constants with identical names but of varying case. However, here's an easy work around.
<syntaxhighlight lang="futurebasic">CFDictionaryRef canines
canines = @{@"dog":@"Benjamin", @"Dog":@"Samba", @"DOG":@"Bernie"}
print "The three dogs are "; canines[@"dog"]; ", "; canines[@"Dog"]; " and "; canines[@"DOG"]; "."
 
HandleEvents</syntaxhighlight>
{{out}}
<pre>There are three dogs named Benjamin, Samba and Bernie.</pre>
 
==={{header|GW-BASIC}}===
{{works with|PC-BASIC|any}}
GW-BASIC is case-insensitive. GW-BASIC keyword tokens and variable names get converted to upper case in programs.
<syntaxhighlight lang="qbasic">10 dog$ = "Benjamin"
20 dog$ = "Smokey"
30 dog$ = "Samba"
40 dog$ = "Bernie"
50 print "There is just one dog, named ";dog$</syntaxhighlight>
{{out}}
<pre>There is just one dog, named Bernie</pre>
 
==={{header|Liberty BASIC}}===
{{works with|Just BASIC}}
Just BASIC and Liberty BASIC names are case sensitive
 
NB the IDE warns you that there are similar variables named dog$, Dog$ & DOG$
<syntaxhighlight lang="lb">
dog$ = "Benjamin"
Dog$ = "Samba"
DOG$ = "Bernie"
print "The three dogs are "; dog$; ", "; Dog$; " and "; DOG$; "."
 
end</syntaxhighlight>
{{out}}
<pre>The three dogs are Benjamin, Samba and Bernie.</pre>
 
==={{header|Minimal BASIC}}===
Minimal BASIC is case-insensitive. Minimal BASIC convert all input characters to upper case.
<syntaxhighlight lang="qbasic">10 let d$ = "Benjamin"
20 let D$ = "Samba"
30 print "There is just one dog, named "; d$
40 end</syntaxhighlight>
{{out}}
<pre>THERE IS JUST ONE DOG, NAMED SAMBA</pre>
 
==={{header|MSX Basic}}===
{{works with|MSX BASIC|any}}
MSX BASIC is case-insensitive. MSX-BASIC keyword tokens and variable names get converted to upper case in programs.
<syntaxhighlight lang="qbasic">10 dog$ = "Benjamin"
20 dog$ = "Smokey"
30 dog$ = "Samba"
40 dog$ = "Bernie"
50 print "There is just one dog, named ";dog$</syntaxhighlight>
{{out}}
<pre>There is just one dog, named Bernie</pre>
 
==={{header|PureBasic}}===
<syntaxhighlight lang="purebasic">dog$="Benjamin"
Dog$="Samba"
DOG$="Bernie"
Debug "There is just one dog named "+dog$</syntaxhighlight>
 
==={{header|QBasic}}===
QBASIC is case-insensitive
<syntaxhighlight lang="basic256">DOG$ = "Benjamin"
DOG$ = "Samba"
DOG$ = "Bernie"
PRINT "There is just one dog, named "; DOG$</syntaxhighlight>
 
==={{header|Quite BASIC}}===
Quite BASIC is case-insensitive
<syntaxhighlight lang="qbasic">10 let d$ = "Benjamin"
20 let D$ = "Samba"
30 print "There is just one dog, named "; d$
40 end</syntaxhighlight>
{{out}}
<pre>There is just one dog, named Samba</pre>
 
==={{header|Run BASIC}}===
{{works with|Just BASIC}}
{{works with|Liberty BASIC}}
Run BASIC names are case sensitive
<syntaxhighlight lang="runbasic">
dog$ = "Benjamin"
doG$ = "Smokey"
Dog$ = "Samba"
DOG$ = "Bernie"
print "The 4 dogs are "; dog$; ", "; doG$; ", "; Dog$; " and "; DOG$; "."</syntaxhighlight>
{{out}}
<pre>The 4 dogs are Benjamin, Smokey, Samba and Bernie.</pre>
 
==={{header|True BASIC}}===
{{works with|QBasic}}
True Basic is case-insensitive
<syntaxhighlight lang="qbasic">LET dog$ = "Benjamin"
LET Dog$ = "Samba"
LET DOG$ = "Bernie"
PRINT "There is just one dog, named "; dog$
END</syntaxhighlight>
 
==={{header|XBasic}}===
XBasic in case-insensitive
<syntaxhighlight lang="qbasic">PROGRAM "Case-sensitivity"
VERSION "0.0000"
 
DECLARE FUNCTION Entry ()
 
FUNCTION Entry ()
dog$ = "Benjamin"
dog$ = "Smokey"
dog$ = "Samba"
dog$ = "Bernie"
PRINT "There is just one dog, named "; dog$
END FUNCTION
END PROGRAM</syntaxhighlight>
{{out}}
<pre>There is just one dog, named Bernie</pre>
 
==={{header|Yabasic}}===
Yabasic names are case sensitive:
<syntaxhighlight lang="yabasic">
dog$ = "Benjamin"
doG$ = "Smokey"
Dog$ = "Samba"
DOG$ = "Bernie"
print "The four dogs are named ", dog$, ", ", doG$, ", ", Dog$, " and ", DOG$
end</syntaxhighlight>
{{out}}
<pre>The four dogs are named Benjamin, Smokey, Samba and Bernie</pre>
 
==={{header|ZX Spectrum Basic}}===
<syntaxhighlight lang="basic">10 LET D$="Benjamin"
20 PRINT "There is just one dog named ";d$</syntaxhighlight>
 
=={{header|Batch File}}==
<langsyntaxhighlight lang="dos">
@echo off
 
Line 180 ⟶ 383:
echo There is just one dog named %dog%.
pause>nul
</syntaxhighlight>
</lang>
{{out}}
<pre>
There is just one dog named Bernie.
</pre>
 
=={{header|BBC BASIC}}==
<lang bbcbasic> dog$ = "Benjamin"
Dog$ = "Samba"
DOG$ = "Bernie"
PRINT "The three dogs are " dog$ ", " Dog$ " and " DOG$ "."</lang>
Output:
<pre>The three dogs are Benjamin, Samba and Bernie.</pre>
 
=={{header|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.
 
<langsyntaxhighlight lang="bc">obase = 16
ibase = 16
 
Line 206 ⟶ 401:
d = BE27A312
"There is just one dog named "; d
quit</langsyntaxhighlight>
 
There is just one dog named BE27A312
 
=={{header|Bracmat}}==
<langsyntaxhighlight Bracmatlang="bracmat">( Benjamin:?dog
& Samba:?Dog
& Bernie:?DOG
& out$("There are three dogs:" !dog !Dog and !DOG)
);</langsyntaxhighlight>
Output:
<pre>There are three dogs: Benjamin Samba and Bernie</pre>
 
=={{header|Brlcad}}==
 
The three dogs are drawn as spheres in this simple example:
 
<langsyntaxhighlight lang="mged">
opendb dogs.g y # Create a database to hold our dogs
units ft # The dogs are measured in feet
Line 229 ⟶ 422:
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</langsyntaxhighlight>
 
=={{header|C}}==
C is case sensitive; if it would be case insensitive, an error about redefinition of a variable would be raised.
 
<langsyntaxhighlight lang="c">#include <stdio.h>
 
static const char *dog = "Benjamin";
Line 244 ⟶ 436:
printf("The three dogs are named %s, %s and %s.\n", dog, Dog, DOG);
return 0;
}</langsyntaxhighlight>
=={{header|C sharp|C#}}==
 
=={{header|C sharp}}==
C# is case sensitive
<langsyntaxhighlight Clang="c sharp">
using System;
 
Line 260 ⟶ 451:
Console.WriteLine(string.Format("The three dogs are named {0}, {1}, and {2}.", dog, Dog, DOG));
}
}</langsyntaxhighlight>
 
=={{header|C++}}==
C++ is case-sensitive.
<langsyntaxhighlight lang="cpp">#include <iostream>
#include <string>
using namespace std;
Line 272 ⟶ 462:
cout << "The three dogs are named " << dog << ", " << Dog << ", and " << DOG << endl;
}</langsyntaxhighlight>
{{out}}
<pre>The three dogs are named Benjamin, Samba, and Bernie</pre>
 
=={{header|Clojure}}==
<pre>user=> (let [dog "Benjamin" Dog "Samba" DOG "Bernie"] (format "The three dogs are named %s, %s and %s." dog Dog DOG))
"The three dogs are named Benjamin, Samba and Bernie."</pre>
 
=={{header|COBOL}}==
<langsyntaxhighlight lang="cobol *">* Case sensitivity of identifiers
*>* Commented-out lines in the working storage
*>* are considered as invalid redefinitions
Line 301 ⟶ 489:
END-DISPLAY
STOP RUN.
END PROGRAM case-sensitivity.</langsyntaxhighlight>
 
=={{header|CoffeeScript}}==
<langsyntaxhighlight lang="coffeescript">
dog="Benjamin"
Dog = "Samba"
DOG = "Bernie"
console.log "The three dogs are names #{dog}, #{Dog}, and #{DOG}."
</syntaxhighlight>
</lang>
 
output
<syntaxhighlight lang="text">
> coffee foo.coffee
The three dogs are names Benjamin, Samba, and Bernie.
</syntaxhighlight>
</lang>
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang="lisp">CL-USER> (let* ((dog "Benjamin") (Dog "Samba") (DOG "Bernie"))
(format nil "There is just one dog named ~a." dog))
; in: LAMBDA NIL
Line 332 ⟶ 518:
; compilation unit finished
; caught 2 STYLE-WARNING conditions
"There is just one dog named Bernie."</langsyntaxhighlight>
 
These are the style warnings from [[SBCL]]. Other implementations of Common Lisp might give different warnings.
=={{header|Cowgol}}==
<syntaxhighlight lang="cowgol">include "cowgol.coh";
 
var dog := "Benjamin";
var Dog := "Samba";
var DOG := "Bernie";
 
print("There are three dogs named ");
print(dog);
print(", ");
print(Dog);
print(", and ");
print(DOG);
print(".\n");</syntaxhighlight>
{{out}}
<pre>There are three dogs named Benjamin, Samba, and Bernie.</pre>
 
=={{header|Crystal}}==
<langsyntaxhighlight lang="crystal">dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
 
puts "The three dogs are named #{dog}, #{Dog} and #{DOG}."</langsyntaxhighlight>
Note that in Crystal, variables with all-caps identifiers (like <code>DOG</code>) are always constants.
 
Line 348 ⟶ 550:
 
=={{header|D}}==
<langsyntaxhighlight lang="d">import std.stdio;
 
void main() {
Line 357 ⟶ 559:
writefln("There are three dogs named ",
dog, ", ", Dog, ", and ", DOG, "'");
}</langsyntaxhighlight>
Output:
<pre>There are three dogs named Benjamin, Samba, and Bernie'</pre>
 
=={{header|Dart}}==
Dart names are case sensitive
 
note: The name of the variables 'Dog' and 'DOG' is not a lowerCamelCase identifier.
<syntaxhighlight lang="dart">void main() {
String dog = "Benjamin", doG = "Smokey", Dog = "Samba", DOG = "Bernie";
 
print("The four dogs are named $dog, $doG, $Dog and $DOG");
}</syntaxhighlight>
{{out}}
<pre>The four dogs are named Benjamin, Smokey, Samba and Bernie</pre>
 
=={{header|dc}}==
A register name has only one character, so this example uses 'd' and 'D'.
 
<langsyntaxhighlight lang="dc">[Benjamin]sd
[Samba]sD
[The two dogs are named ]P ldP [ and ]P lDP [.
]P</langsyntaxhighlight>
 
{{Out}}
<pre>The two dogs are named Benjamin and Samba.</pre>
 
=={{header|Delphi}}==
Delphi is case insensitive.
 
<langsyntaxhighlight Delphilang="delphi">program CaseSensitiveIdentifiers;
 
{$APPTYPE CONSOLE}
Line 386 ⟶ 599:
DOG := 'Bernie';
Writeln('There is just one dog named ' + dog);
end.</langsyntaxhighlight>
 
Output:
<pre>There is just one dog named Bernie</pre>
 
=={{header|DWScript}}==
<syntaxhighlight lang="delphi">
<lang Delphi>
var dog : String;
 
Line 399 ⟶ 611:
DOG := 'Bernie';
 
PrintLn('There is just one dog named ' + dog);</langsyntaxhighlight>
 
Output:
<pre>There is just one dog named Bernie</pre>
 
=={{header|Déjà Vu}}==
<langsyntaxhighlight lang="dejavu">local :dog "Benjamin"
local :Dog "Samba"
local :DOG "Bernie"
!print( "There are three dogs named " dog ", " Dog " and " DOG "." )</langsyntaxhighlight>
{{out}}
<pre>There are three dogs named Benjamin, Samba and Bernie.</pre>
 
=={{header|Draco}}==
<syntaxhighlight lang="draco">proc main() void:
*char dog = "Benjamin",
Dog = "Samba",
DOG = "Bernie";
 
writeln("There are three dogs named ",
dog, ", ", Dog, ", and ", DOG, ".")
corp</syntaxhighlight>
{{out}}
<pre>There are three dogs named Benjamin, Samba, and Bernie.</pre>
 
=={{header|EasyLang}}==
EasyLang is case-sensitive.
<syntaxhighlight lang="easylang">dog$ = "Benjamin"
Dog$ = "Samba"
DOG$ = "Bernie"
#
print "The three dogs are named " & dog$ & ", " & Dog$ & ", and " & DOG$ & "."</syntaxhighlight>
 
=={{header|EchoLisp}}==
<langsyntaxhighlight lang="scheme">
(define dog "Benjamin")
(define Dog "Samba")
Line 421 ⟶ 652:
(printf "The three dogs are named %a, %a and %a. " dog Dog DOG)
The three dogs are named Benjamin, Samba and Bernie.
</syntaxhighlight>
</lang>
 
=={{header|Ecstasy}}==
<syntaxhighlight lang="java">
String dog = "Benjamin"; // convention: lower camelCase for variable and property names
String Dog = "Samba"; // convention: upper CamelCase for class, type, and constant names
String DOG = "Bernie"; // convention: all-caps only for constants
 
@Inject Console console;
console.print($"There are three dogs named {dog}, {Dog}, and {DOG}");
</syntaxhighlight>
 
=={{header|Elena}}==
In ELENA identifiers are case sensitive.
ELENA 4.x:
<langsyntaxhighlight lang="elena">import extensions;
 
public program()
Line 434 ⟶ 675:
var DOG := "Bernie";
console.printLineFormatted("The three dogs are named {0}, {1} and {2}", dog, Dog, DOG)
}</langsyntaxhighlight>
{{out}}
<pre>
The three dogs are named Benjamin, Samba and Bernie
</pre>
 
=={{header|Elixir}}==
While Elixir's identifiers are case-sensitive, they generally must start with a lowercase letter. Capitalized identifiers are reserved for modules.
<langsyntaxhighlight lang="elixir">dog = "Benjamin"
doG = "Samba"
dOG = "Bernie"
IO.puts "The three dogs are named #{dog}, #{doG} and #{dOG}."</langsyntaxhighlight>
 
{{out}}
Line 451 ⟶ 691:
The three dogs are named Benjamin, Samba and Bernie.
</pre>
 
=={{header|Erlang}}==
Erlang variables are case sensitive but must start with an uppercase letter.
<syntaxhighlight lang="erlang">
<lang Erlang>
-module( case_sensitivity_of_identifiers ).
 
Line 464 ⟶ 703:
DOG = "Bernie",
io:fwrite( "The three dogs are named ~s, ~s and ~s~n", [dog, Dog, DOG] ).
</syntaxhighlight>
</lang>
 
{{out}}
Line 471 ⟶ 710:
The three dogs are named dog, Samba and Bernie
</pre>
 
=={{header|Euphoria}}==
{{works with|Euphoria|4.0.0}}
<langsyntaxhighlight Euphorialang="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} )</langsyntaxhighlight>
 
=={{header|F Sharp|F#}}==
F# is case-sensitive.
<langsyntaxhighlight lang="fsharp">let dog = "Benjamin"
let Dog = "Samba"
let DOG = "Bernie"
printfn "There are three dogs named %s, %s and %s" dog Dog DOG</langsyntaxhighlight>
 
=={{header|Factor}}==
Factor identifiers are case-sensitive.
<langsyntaxhighlight lang="factor">USING: formatting locals ;
IN: scratchpad
[let
Line 496 ⟶ 732:
"Bernie" :> DOG
{ dog Dog DOG } "There are three dogs named %s, %s, and %s." vprintf
]</langsyntaxhighlight>
{{out}}
<pre>
There are three dogs named Benjamin, Samba, and Bernie.
</pre>
 
=={{header|Forth}}==
<langsyntaxhighlight lang="forth">: DOG ." Benjamin" ;
: Dog ." Samba" ;
: dog ." Bernie" ;
: HOWMANYDOGS ." There is just one dog named " DOG ;
HOWMANYDOGS</langsyntaxhighlight>
{{out}}
<pre>There is just one dog named Bernie</pre>
 
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
Fortran is case insensitive, and so the three "dog" variants name the same variable - which therefore is multiply declared and will likely evoke a compiler complaint.
<langsyntaxhighlight lang="fortran">program Example
implicit none
 
Line 529 ⟶ 763:
end if
 
end program Example</langsyntaxhighlight>
Output:
<pre> There is just one dog named Bernie</pre>
 
=={{header|FreeBASIC}}==
<lang freebasic>' FB 1.05.0 Win64
 
' FreeBASIC is case-insensitive
Dim dog As String
dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
Print "There is just one dog, named "; dog
Sleep</lang>
 
{{out}}
<pre>
There is just one dog, named Bernie
</pre>
 
=={{header|Frink}}==
Frink is case-sensitive.
<langsyntaxhighlight lang="frink">dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
println["There are three dogs named $dog, $Dog and $DOG"]</langsyntaxhighlight>
 
 
=={{header|Gambas}}==
Line 560 ⟶ 778:
 
Gambas in case insensitive
<langsyntaxhighlight lang="gambas">Public Sub Main()
Dim dog As String
 
Line 568 ⟶ 786:
Print "There is just one dog, named "; dog
 
End</langsyntaxhighlight>
Output:
<pre>
There is just one dog, named Bernie
</pre>
 
=={{header|GAP}}==
<langsyntaxhighlight lang="gap"># GAP is case sensitive
ThreeDogs := function()
local dog, Dog, DOG;
Line 589 ⟶ 806:
 
ThreeDogs();
# The three dogs are named Benjamin, Samba and Bernie</langsyntaxhighlight>
 
=={{header|Go}}==
Go is case sensitive. Further, visibility depends on case. See the Go entry under the [[Scope_modifiers#Go|Scope modifiers]] task.
<langsyntaxhighlight lang="go">package dogs
 
import "fmt"
Line 611 ⟶ 827:
// the variables really represent different places in memory.
return map[*string]int{&dog: 1, &Dog: 1, &DOG: 1}
}</langsyntaxhighlight>
<langsyntaxhighlight lang="go">package main
 
import (
Line 658 ⟶ 874:
d[&DOG] = 1
fmt.Println("There are", len(d), "dogs.")
}</langsyntaxhighlight>
{{out}}
<pre>
Line 676 ⟶ 892:
There are 5 dogs.
</pre>
 
=={{header|Groovy}}==
Solution:
<langsyntaxhighlight lang="groovy">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}.")</langsyntaxhighlight>
 
Output:
<pre>There are three dogs named Benjamin, Samba and Bernie.</pre>
 
=={{header|Haskell}}==
Identifiers are case sensitive in Haskell, but must start with a lower case letter.
 
<langsyntaxhighlight Haskelllang="haskell">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"</langsyntaxhighlight>
 
=={{header|Icon}} and {{header|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.
<langsyntaxhighlight Iconlang="icon">procedure main()
 
dog := "Benjamin"
Line 708 ⟶ 921:
write("The three dogs are named ", dog, ", ", Dog, " and ", DOG, ".")
 
end</langsyntaxhighlight>
 
=={{header|J}}==
<langsyntaxhighlight 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 </langsyntaxhighlight>
 
=={{header|Java}}==
<langsyntaxhighlight 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 + "'");</langsyntaxhighlight>
 
=={{header|JavaScript}}==
Javascript is case sensitive.
<langsyntaxhighlight lang="javascript">var dog = "Benjamin";
var Dog = "Samba";
var DOG = "Bernie";
document.write("The three dogs are named " + dog + ", " + Dog + ", and " + DOG + ".");</langsyntaxhighlight>
 
=={{header|jq}}==
jq identifiers are case-sensitive.
 
'''Function parameters''':
<langsyntaxhighlight lang="jq">def task(dog; Dog; DOG):
"The three dogs are named \(dog), \(Dog), and \(DOG)." ;
 
task("Benjamin"; "Samba"; "Bernie")</langsyntaxhighlight>
 
{{Out}}
Line 746 ⟶ 955:
 
'''Variable names''':
<langsyntaxhighlight lang="jq">"Benjamin" as $dog | "Samba" as $Dog | "Bernie" as $DOG
| "The three dogs are named \($dog), \($Dog), and \($DOG)."</langsyntaxhighlight>
{{out}}
As above.
 
=={{header|Julia}}==
{{works with|Julia|0.6}}
Variable names are case sensitive.
<langsyntaxhighlight lang="julia">dog, Dog, DOG = "Benjamin", "Samba", "Bernie"
 
if dog === Dog
Line 760 ⟶ 968:
else
println("The three dogs are: ", dog, ", ", Dog, " and ", DOG)
end</langsyntaxhighlight>
 
{{out}}
Line 766 ⟶ 974:
 
Conventionally, variable names should be all lower case. Type and Macro names should be capitalized.
 
=={{header|K}}==
<syntaxhighlight lang="k">
<lang k>
dog: "Benjamin"
Dog: "Samba"
Line 774 ⟶ 981:
"There are three dogs named ",dog,", ",Dog," and ",DOG
"There are three dogs named Benjamin, Samba and Bernie"
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
Kotlin is case-sensitive though (as in Java) the convention is for local variable names to begin with a lower case letter. The second and third identifiers would therefore be unlikely to be used in practice.
<langsyntaxhighlight lang="scala">fun main(args: Array<String>) {
val dog = "Benjamin"
val Dog = "Samba"
val DOG = "Bernie"
println("The three dogs are named $dog, $Dog and $DOG")
}</langsyntaxhighlight>
 
{{out}}
Line 789 ⟶ 995:
The three dogs are named Benjamin, Samba and Bernie
</pre>
 
=={{header|Lasso}}==
Lasso is not case sensitive for names
<syntaxhighlight lang="lasso">
<lang Lasso>
local(dog = 'Benjamin')
local(Dog = 'Samba')
Line 798 ⟶ 1,003:
 
stdoutnl('There is just one dog named ' + #dog)
</syntaxhighlight>
</lang>
Output:
<pre>There is just one dog named Bernie</pre>
 
Same with string comparisons. (Lasso maps can only contain unique keys)
<syntaxhighlight lang="lasso">
<lang Lasso>
local(dogs = map(
'dog' = 'Benjamin',
Line 809 ⟶ 1,014:
'DOG' = 'Bernie'
))
stdoutnl(#dogs -> size)</langsyntaxhighlight>
Output:
<pre>1</pre>
 
To get case sensitivity we need to use bytes
<syntaxhighlight lang="lasso">
<lang Lasso>
local(dogs = map(
bytes('dog') = 'Benjamin',
Line 823 ⟶ 1,028:
stdoutnl(#dogs -> size)
 
stdoutnl(#dogs -> find(bytes('Dog')))</langsyntaxhighlight>
Output:
<pre>3
Samba </pre>
=={{header|Logtalk}}==
 
In Logtalk, as in the underlying Prolog, variables must begin with an uppercase character or an underscore. Thus the task as written cannot be performed but an analogous one can be.
=={{header|Liberty BASIC}}==
NB the IDE warns you that there are similar variables named dog$, Dog$ & DOG$
<lang lb>
dog$ = "Benjamin"
Dog$ = "Samba"
DOG$ = "Bernie"
print "The three dogs are "; dog$; ", "; Dog$; " and "; DOG$; "."
 
<syntaxhighlight lang="logtalk">
end
:- object(three_dogs_or_one).
</lang>
 
The three dogs are Benjamin, Samba and Bernie.
:- public(test/0).
 
test :-
fill_dogs(DOG, Dog, DoG),
write_message(DOG, Dog, DoG).
 
% Note: this predicate would actually fail if variables weren't case sensitive...
fill_dogs('Benjamin', 'Samba', 'Bernie').
 
% Note: ...as a result there is no way for this clause to ever succeed.
write_message(A, A, A) :-
format('There is one dog named ~w.~n', [A]).
 
write_message(A, B, C) :-
A \= B, B \= C, A \= C,
format('There are three dogs named ~w, ~w, and ~w.~n', [A, B, C]).
 
:- end_object.
</syntaxhighlight>
 
{{Out}}
 
<pre>
?- {dogs}.
% ... messages elided
?- true.
 
?- three_dogs_or_one::test.
There are three dogs named Benjamin, Samba, and Bernie.
true.
?-
</pre>
 
=={{header|Lua}}==
<langsyntaxhighlight lang="lua">dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
 
print( "There are three dogs named "..dog..", "..Dog.." and "..DOG.."." )</langsyntaxhighlight>
<pre>There are three dogs named Benjamin, Samba and Bernie.</pre>
 
Line 853 ⟶ 1,085:
Types in Enumeration are case sensitive, identifiers are not case sensitive.
 
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
MoDuLe CheckIT {
\\ keys as case sensitive if they are strings
Line 880 ⟶ 1,112:
}
Checkit
</syntaxhighlight>
</lang>
 
=={{header|Maple}}==
<syntaxhighlight lang="text">> 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 )
Line 891 ⟶ 1,122:
> printf( "There is one dog named %s.\n", dog )
> end if:
There are three dogs named Benjamin, Samba and Bernie.</langsyntaxhighlight>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="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"</langsyntaxhighlight>
 
=={{header|MATLAB}} / {{header|Octave}}==
 
<langsyntaxhighlight Matlablang="matlab"> dog = 'Benjamin';
Dog = 'Samba';
DOG = 'Bernie';
 
printf('There are three dogs %s, %s, %s.\n',dog, Dog, DOG); </langsyntaxhighlight>
 
Output
 
<pre> There are three dogs Benjamin, Samba, Bernie. </pre>
 
=={{header|Maxima}}==
<langsyntaxhighlight lang="maxima">/* Maxima is case sensitive */
a: 1$
A: 2$
 
is(a = A);
false</langsyntaxhighlight>
 
=={{header|min}}==
{{works with|min|0.1937.30}}
min's symbols are case sensitive.
<langsyntaxhighlight lang="min">"Benjamin" :dog
"Samba" :Dog
"Bernie" :DOG
 
"There are three dogs named $1, $2, and $3." (dog Dog DOG)=> =% printputs!</langsyntaxhighlight>
{{out}}
<pre>There are three dogs named Benjamin, Samba, and Bernie.</pre>
<pre>
There are three dogs named Benjamin, Samba, and Bernie.
</pre>
 
=={{header|MiniScript}}==
<langsyntaxhighlight MiniScriptlang="miniscript">dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
 
print "There are three dogs named " + dog + ", " + Dog + " and " + DOG</langsyntaxhighlight>
 
=={{header|Modula-2}}==
<langsyntaxhighlight lang="modula2">MODULE dog;
 
IMPORT InOut;
Line 953 ⟶ 1,178:
InOut.WriteString ("Three happy dogs.");
InOut.WriteLn
END dog.</langsyntaxhighlight>
 
=={{header|N/t/roff}}==
In groff, string variables are case sensitive.
<syntaxhighlight lang="nroff">
.ds dog Benjamin
.ds Dog Samba
.ds DOG Bernie
The three dogs are named \*[dog], \*[Dog] and \*[DOG].
</syntaxhighlight>
{{out}}
<pre>The three dogs are named Benjamin, Samba and Bernie.
</pre>
 
=={{header|Nanoquery}}==
<langsyntaxhighlight lang="nanoquery">dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
 
print format("The three dogs are named %s, %s, and %s.\n", dog, Dog, DOG)</langsyntaxhighlight>
{{out}}
<pre>The three dogs are named Benjamin, Samba, and Bernie.</pre>
 
=={{header|Nemerle}}==
<langsyntaxhighlight Nemerlelang="nemerle">def dog = "Benjamin";
def Dog = "Samba";
def DOG = "Bernie";
WriteLine($"The three dogs are named $dog, $Dog, and $DOG");</langsyntaxhighlight>
 
=={{header|NESL}}==
NESL is completely case-insensitive.
<langsyntaxhighlight lang="nesl">dog = "Benjamin";
Dog = "Samba";
DOG = "Bernie";
"There is just one dog, named " ++ dog;</langsyntaxhighlight>
{{out}}
<pre>it = "There is just one dog, named Bernie" : [char]</pre>
 
=={{header|NetRexx}}==
NetRexx is not case sensitive:
<langsyntaxhighlight NetRexxlang="netrexx">/* NetRexx */
options replace format comments java crossref symbols nobinary
 
Line 996 ⟶ 1,231:
 
return
</syntaxhighlight>
</lang>
'''Output:'''
<pre>
There is just one dog named Bernie.
</pre>
 
=={{header|Nim}}==
Nim has peculiar rules regarding case and style sensitivity:
Line 1,011 ⟶ 1,245:
With these rules, we don’t get one dog or three dogs: we get two dogs!
 
<langsyntaxhighlight Nimlang="nim">var dog, Dog: string
(dog, Dog, DOG) = ("Benjamin", "Samba", "Bernie")
Line 1,022 ⟶ 1,256:
echo "There are two dogs: ", dog, " and ", DOG
else:
echo "There are three dogs: ", dog, ", ", Dog, " and ", DOG</langsyntaxhighlight>
 
{{out}}
<pre>There are two dogs: Benjamin and Bernie</pre>
 
=={{header|Oberon-2}}==
{{Works with| oo2c Version 2}}
<langsyntaxhighlight lang="oberon2">
MODULE CaseSensitivity;
IMPORT
Line 1,042 ⟶ 1,275:
Out.Ln
END CaseSensitivity.
</syntaxhighlight>
</lang>
{{Out}}
<pre>
The three dogs are named Benjamin, Samba and Bernie
</pre>
 
=={{header|Objeck}}==
Objeck is case sensitive
 
<langsyntaxhighlight lang="objeck">class Program {
function : Main(args : String[]) ~ Nil {
dog := "Benjamin";
Line 1,058 ⟶ 1,290:
"The three dogs are named {$dog}, {$Dog}, and {$DOG}."->PrintLine();
}
}</langsyntaxhighlight>
 
=={{header|OCaml}}==
 
Identifiers in OCaml are lettercase sensitive, but the first letter has to be lowercase.
 
<langsyntaxhighlight lang="ocaml">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</langsyntaxhighlight>
 
=={{header|Oforth}}==
 
Oforth is case-sensitive.
 
<langsyntaxhighlight Oforthlang="oforth">: threeDogs
| dog Dog DOG |
 
Line 1,081 ⟶ 1,311:
"Bernie" ->DOG
 
System.Out "The three dogs are named " << dog << ", " << Dog << " and " << DOG << "." << cr ;</langsyntaxhighlight>
 
=={{header|Ol}}==
<langsyntaxhighlight lang="scheme">
(define dog "Benjamin")
(define Dog "Samba")
Line 1,090 ⟶ 1,319:
(print "The three dogs are named " dog ", " Dog " and " DOG ".\n")
</syntaxhighlight>
</lang>
{{Out}}
<pre>
The three dogs are named Benjamin, Samba and Bernie.
</pre>
 
 
=={{header|PARI/GP}}==
<langsyntaxhighlight lang="parigp">dog="Benjamin";
Dog="Samba";
DOG="Bernie";
printf("The three dogs are named %s, %s, and %s.", dog, Dog, DOG)</langsyntaxhighlight>
 
=={{header|Pascal}}==
See [[#Delphi|Delphi]]
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl"># These variables are all different
$dog='Benjamin';
$Dog='Samba';
$DOG='Bernie';
print "The three dogs are named $dog, $Dog, and $DOG \n"</langsyntaxhighlight>
 
=={{header|Phix}}==
{{libheader|Phix/basics}}
Phix is case sensitive
 
<!--<langsyntaxhighlight Phixlang="phix">-->
<span style="color: #004080;">sequence</span> <span style="color: #000000;">dog</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"Benjamin"<span style="color: #0000FF;">,</span>
<span style="color: #000000;">Dog</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"Samba"<span style="color: #0000FF;">,</span>
<span style="color: #000000;">DOG</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"Bernie"</span>
<span style="color: #7060A8;">printf<span style="color: #0000FF;">(</span> <span style="color: #000000;">1<span style="color: #0000FF;">,</span> <span style="color: #008000;">"The three dogs are named %s, %s and %s\n"<span style="color: #0000FF;">,</span> <span style="color: #0000FF;">{<span style="color: #000000;">dog<span style="color: #0000FF;">,</span> <span style="color: #000000;">Dog<span style="color: #0000FF;">,</span> <span style="color: #000000;">DOG<span style="color: #0000FF;">}</span> <span style="color: #0000FF;">)
<!--</langsyntaxhighlight>-->
 
{{out}}
Line 1,128 ⟶ 1,352:
The three dogs are named Benjamin, Samba and Bernie
</pre>
=={{header|PHP}}==
<syntaxhighlight lang="PHP"><?php
 
// In true PHP style, this example is inconsistent.
// Variable identifiers are case sensitive
 
$dog = 'Benjamin';
$Dog = 'Samba';
$DOG = 'Bernie';
 
echo "There are 3 dogs named {$dog}, {$Dog} and {$DOG}\n";
 
// Whereas function identifiers are case insensitive
 
function DOG() { return 'Bernie'; }
 
echo 'There is only 1 dog named ' . dog() . "\n";</syntaxhighlight>
 
'''Output:'''
 
There are 3 dogs named Benjamin, Samba and Bernie<br>
There is only 1 dog named Bernie
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(let (dog "Benjamin" Dog "Samba" DOG "Bernie")
(prinl "The three dogs are named " dog ", " Dog " and " DOG) )</langsyntaxhighlight>
Output:
<pre>The three dogs are named Benjamin, Samba and Bernie</pre>
 
=={{header|PL/I}}==
<langsyntaxhighlight lang="pli">*process or(!) source xref attributes macro options;
/*********************************************************************
* Program to show that PL/I is case-insensitive
Line 1,147 ⟶ 1,393:
DOG = "Bernie";
Put Edit(dog,Dog,DOG)(Skip,3(a,x(1)));
End;</langsyntaxhighlight>
'''Output'''
<pre>Bernie Bernie Berni</pre>
 
=={{header|Plain English}}==
Plain English is NOT case sensitive.
<langsyntaxhighlight lang="plainenglish">To run:
Start up.
Put "Benjamin" into a DOG string.
Line 1,160 ⟶ 1,405:
Write "There is just one dog named " then the DOG on the console.
Wait for the escape key.
Shut down.</langsyntaxhighlight>
{{out}}
<pre>
There is just one dog named Bernie
</pre>
 
=={{header|PowerShell}}==
PowerShell is not case sensitive.
<syntaxhighlight lang="powershell">
<lang PowerShell>
$dog = "Benjamin"
$Dog = "Samba"
Line 1,174 ⟶ 1,418:
 
"There is just one dog named {0}." -f $dOg
</syntaxhighlight>
</lang>
{{Out}}
<pre>
There is just one dog named Bernie.
</pre>
 
=={{header|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 :
<langsyntaxhighlight Prologlang="prolog">three_dogs :-
DoG = 'Benjamin',
Dog = 'Samba',
DOG = 'Bernie',
format('The three dogs are named ~w, ~w and ~w.~n', [DoG, Dog, DOG]).
</syntaxhighlight>
</lang>
The output is :
<pre>?- three_dogs.
Line 1,194 ⟶ 1,437:
 
</pre>
=={{header|Python}}==
Python variable names are case sensitive:
<syntaxhighlight lang="python">dog = 'Benjamin'
Dog = 'Samba'
DOG = 'Bernie'
 
print(f"The three dogs are named {dog}, {Dog} and {DOG}.")</syntaxhighlight>
=={{header|PureBasic}}==
<lang PureBasic>dog$="Benjamin"
Dog$="Samba"
DOG$="Bernie"
Debug "There is just one dog named "+dog$</lang>
 
=={{header|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>
 
=={{header|Quackery}}==
<langsyntaxhighlight lang="quackery">[ $ 'Benjamin' ] is dog ( --> $ )
 
[ $ 'Samba' ] is Dog ( --> $ )
Line 1,218 ⟶ 1,455:
dog echo$ say ', '
Dog echo$ say ', and '
DOG echo$ say '.' cr</langsyntaxhighlight>
{{out}}
<pre>
There are three dogs named Benjamin, Samba, and Bernie.
</pre>
 
=={{header|R}}==
<langsyntaxhighlight Rlang="r">dog <- 'Benjamin'
Dog <- 'Samba'
DOG <- 'Bernie'
Line 1,238 ⟶ 1,474:
cat('.\n')
# In one line it would be:
# cat('The three dogs are named ', dog, ', ', Dog, ' and ', DOG, '.\n', sep = '')</langsyntaxhighlight>
 
Output:
Line 1,244 ⟶ 1,480:
The three dogs are named Benjamin, Samba and Bernie.
</pre>
 
=={{header|Racket}}==
The default setting for the Racket reader is to be case sensitive:
<syntaxhighlight lang="racket">
<lang Racket>
#lang racket
(define dog "Benjamin")
Line 1,256 ⟶ 1,491:
(displayln (~a "There is one dog named " DOG "."))
(displayln (~a "The three dogs are named " dog ", " Dog ", and, " DOG ".")))
</syntaxhighlight>
</lang>
Output:
<pre>
Line 1,263 ⟶ 1,498:
 
If you need case insensitive identifiers, then use #ci to turn on case insensitivity:
<syntaxhighlight lang="racket">
<lang Racket>
#lang racket
#ci(module dogs racket
Line 1,273 ⟶ 1,508:
(displayln (~a "The three dogs are named " dog ", " Dog ", and, " DOG "."))))
(require 'dogs)
</syntaxhighlight>
</lang>
Output:
<pre>
There is one dog named Bernie.
</pre>
 
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku" perl6line>my $dog = 'Benjamin';
my $Dog = 'Samba';
my $DOG = 'Bernie';
say "The three dogs are named $dog, $Dog, and $DOG."</langsyntaxhighlight>
The only place that Raku 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 Raku, not mandatory:
<syntaxhighlight lang="raku" perl6line>constant dog = 'Benjamin';
sub Dog() { 'Samba' }
my &DOG = { 'Bernie' }
say "The three dogs are named {dog}, {Dog}, and {DOG}."</langsyntaxhighlight>
 
=={{header|Retro}}==
Retro is case sensitive.
 
<langsyntaxhighlight Retrolang="retro">: dog ( -$ ) "Benjamin" ;
: Dog ( -$ ) "Samba" ;
: DOG ( -$ ) "Bernie" ;
 
DOG Dog dog "The three dogs are named %s, %s, and %s.\n" puts</langsyntaxhighlight>
 
=={{header|REXX}}==
===simple variables===
The REXX language is case insensitive &nbsp; (with respect to simple variables).
<langsyntaxhighlight lang="rexx">/*REXX program demonstrate case insensitivity for simple REXX variable names. */
 
/* ┌──◄── all 3 left─hand side REXX variables are identical (as far as assignments). */
Line 1,318 ⟶ 1,550:
else say 'There is just one dog named:' dog"."
 
/*stick a fork in it, we're all done. */</langsyntaxhighlight>
'''output'''
<pre>
Line 1,328 ⟶ 1,560:
===compound variables===
However, the REXX language is case sensitive &nbsp; (with respect to compound variables, or indices).
<langsyntaxhighlight lang="rexx">/*REXX program demonstrate case sensitive REXX index names (for compound variables). */
 
/* ┌──◄── all 3 indices (for an array variable) are unique (as far as array index). */
Line 1,346 ⟶ 1,578:
_= 'doG'; say "dogname.doG=" dogname._ /* " " " " mixed doG*/
 
/*stick a fork in it, we're all done. */</langsyntaxhighlight>
'''output'''
<pre>
Line 1,356 ⟶ 1,588:
dogname.doG= Rex
</pre>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
dog = "Benjamin"
doG = "Smokey"
Line 1,364 ⟶ 1,595:
DOG = "Bernie"
see "The 4 dogs are : " + dog + ", " + doG + ", " + Dog + " and " + DOG + "."
</syntaxhighlight>
</lang>
=={{header|RPL}}==
RPL designers recommend to use lowercase for local variables, whilst uppercase shall be used for global variables and programs.
≪ "Samba" 'DOG' STO → "Benjamin" "Bernie" Dog dog
≪ '''IF''' DOG dog == '''THEN'''
"Just 1 dog named " DOG +
'''ELSE'''
"3 dogs: " Dog + ", " + DOG + " & " + dog +
'''END'''
≫ ≫ EVAL
{{out}}
<pre>
1: "3 dogs: Benjamin, Samba & Bernie"
</pre>
 
=={{header|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 <tt>dog</tt> is a local variable, but <tt>Dog</tt> and <tt>DOG</tt> are constants. To adapt this task to Ruby, I added <tt>dOg</tt> and <tt>doG</tt> so that I have more than one local variable.
 
<langsyntaxhighlight lang="ruby">module FiveDogs
dog = "Benjamin"
dOg = "Dogley"
Line 1,382 ⟶ 1,626:
puts "The local variables are %s." % local_variables.join(", ")
puts "The constants are %s." % constants.join(", ")
end</langsyntaxhighlight>
 
Output: <pre>There are 5 dogs named Benjamin, Dogley, Fido, Samba, Bernie.
Line 1,389 ⟶ 1,633:
The constants are Dog, DOG.</pre>
 
=={{header|Run BASIC}}==
<lang runbasic>
dog$ = "Benjamin"
doG$ = "Smokey"
Dog$ = "Samba"
DOG$ = "Bernie"
print "The 4 dogs are "; dog$; ", "; doG$; ", "; Dog$; " and "; DOG$; "."
</lang>
 
=={{header|Rust}}==
Rust style dictates that identifiers should be written in snake case, e.g. <tt>big_dog</tt>, <tt>small_dog</tt>; whereas types (structs and enums) should be written in camel case, e.g. <tt>BigDog</tt>, <tt>SmallDog</tt>. Failing to comply with this standard does not cause a compiler error, but it will trigger a compiler warning, and the culture is very strongly towards compliance with this standard.
 
<langsyntaxhighlight lang="rust">fn main() {
let dog = "Benjamin";
let Dog = "Samba";
let DOG = "Bernie";
println!("The three dogs are named {}, {} and {}.", dog, Dog, DOG);
}</langsyntaxhighlight>
 
This triggers two warnings at compilation:
 
<syntaxhighlight lang="text"><anon>:3:9: 3:12 warning: variable `Dog` should have a snake case name such as `dog`, #[warn(non_snake_case)] on by default
<anon>:3 let Dog = "Samba";
^~~
<anon>:4:9: 4:12 warning: variable `DOG` should have a snake case name such as `dog`, #[warn(non_snake_case)] on by default
<anon>:4 let DOG = "Bernie";
^~~</langsyntaxhighlight>
 
The resulting program will compile and run just fine, producing the output:
 
<syntaxhighlight lang="text">The three dogs are named Benjamin, Samba and Bernie.</langsyntaxhighlight>
 
=={{header|Sather}}==
Though by convention Sather uses all uppercase letters for class names, a variable can be
all uppercase.
 
<langsyntaxhighlight lang="sather">class MAIN is
main is
dog ::= "Benjamin";
Line 1,433 ⟶ 1,668:
dog, Dog, DOG);
end;
end;</langsyntaxhighlight>
 
Outputs:
 
<pre>The three dogs are Benjamin, Samba and Bernie</pre>
 
=={{header|Scala}}==
<langsyntaxhighlight lang="scala">val dog = "Benjamin"
val Dog = "Samba"
val DOG = "Bernie"
println("There are three dogs named " + dog + ", " + Dog + ", and " + DOG + ".")</langsyntaxhighlight>
Output:
<pre>There are three dogs named Benjamin, Samba, and Bernie.</pre>
 
=={{header|Scheme}}==
Output may differ depending on implementation.
<langsyntaxhighlight lang="scheme">(define dog "Benjamin")
(define Dog "Samba")
(define DOG "Bernie")
Line 1,463 ⟶ 1,696:
(display DOG)
(display ".")
(newline)))</langsyntaxhighlight>
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
 
const string: dog is "Benjamin";
Line 1,475 ⟶ 1,707:
begin
writeln("The three dogs are named " <& dog <& ", " <& Dog <& " and " <& DOG <& ".");
end func;</langsyntaxhighlight>
 
=={{header|SenseTalk}}==
As a People Oriented Programming language, SenseTalk's variable names are case-insensitive.
<langsyntaxhighlight lang="sensetalk">
set dog to "Benjamin"
set Dog to "Samba"
Line 1,485 ⟶ 1,716:
 
put !"There is just one dog named [[dog]]."
</syntaxhighlight>
</lang>
{{out}}
<pre>There is just one dog named Bernie.</pre>
 
=={{header|SETL}}==
<langsyntaxhighlight lang="pascal">dog := 'Benjamin';
Dog := 'Samba';
DOG := 'Bernie';
print( 'There is just one dog named', dOg );</langsyntaxhighlight>
{{out}}
<pre>There is just one dog named Bernie</pre>
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">var dog = 'Benjamin';
var Dog = 'Samba';
var DOG = 'Bernie';
say "The three dogs are named #{dog}, #{Dog}, and #{DOG}.";</langsyntaxhighlight>
{{out}}
<pre>The three dogs are named Benjamin, Samba, and Bernie.</pre>
 
=={{header|Simula}}==
Simula identifiers are case-insensitive, and the compiler will indignantly reject a program that tries to declare multiple variables with names differing only in case. (Same with ''key words'': Case of a character in Simula ''code'' generally only matters in [http://simula67.at.ifi.uio.no/Standard-86/chap_1.htm| a simple string or a character constant].)
<langsyntaxhighlight lang="simula">begin
text dog;
dog :- blanks( 8 );
Line 1,516 ⟶ 1,744:
outtext( dog );
outimage
end</langsyntaxhighlight>
{{out}}
<pre>There is just one dog, named Bernie</pre>
 
=={{header|Smalltalk}}==
{{works with|GNU Smalltalk}}
Line 1,525 ⟶ 1,752:
Smalltalk's symbols are case sensitive.
 
<langsyntaxhighlight lang="smalltalk">|dog Dog DOG|
dog := 'Benjamin'.
Dog := 'Samba'.
DOG := 'Bernie'.
( 'The three dogs are named %1, %2 and %3' %
{ dog . Dog . DOG } ) displayNl.</langsyntaxhighlight>
 
Outputs:
 
<pre>The three dogs are named Benjamin, Samba and Bernie</pre>
 
=={{header|SNOBOL4}}==
<langsyntaxhighlight lang="snobol4"> DOG = 'Benjamin'
Dog = 'Samba'
dog = 'Bernie'
OUTPUT = 'The three dogs are named ' DOG ', ' Dog ', and ' dog
END</langsyntaxhighlight>
{{out}}
<pre>The three dogs are named Benjamin, Samba, and Bernie</pre>
 
=={{header|Standard ML}}==
Standard ML is case sensitive.
<langsyntaxhighlight lang="sml">let
val dog = "Benjamin"
val Dog = "Samba"
Line 1,553 ⟶ 1,778:
in
print("The three dogs are named " ^ dog ^ ", " ^ Dog ^ ", and " ^ DOG ^ ".\n")
end;</langsyntaxhighlight>
{{out}}
<pre>The three dogs are named Benjamin, Samba, and Bernie.</pre>
 
=={{header|Stata}}==
Stata is case-sensitive.
 
<langsyntaxhighlight lang="stata">. local dog Benjamin
. local Dog Samba
. local DOG Bernie
. display "The three dogs are named $_dog, $_Dog, and $_DOG."
The three dogs are named Benjamin, Samba, and Bernie.</langsyntaxhighlight>
 
=={{header|Swift}}==
<langsyntaxhighlight lang="swift">let dog = "Benjamin"
let Dog = "Samba"
let DOG = "Bernie"
println("The three dogs are named \(dog), \(Dog), and \(DOG).")</langsyntaxhighlight>
 
=={{header|Tcl}}==
Tcl variable names are case sensitive:
<langsyntaxhighlight lang="tcl">set dog "Benjamin"
set Dog "Samba"
set DOG "Bernie"
puts "The three dogs are named $dog, $Dog and $DOG"</langsyntaxhighlight>
Which prints...
<pre>The three dogs are named Benjamin, Samba and Bernie</pre>
 
=={{header|UNIX Shell}}==
<langsyntaxhighlight lang="sh">dog="Benjamin"
Dog="Samba"
DOG="Bernie"
echo "The three dogs are named $dog, $Dog and $DOG."</langsyntaxhighlight>
 
The three dogs are named Benjamin, Samba and Bernie.
 
=={{header|Ursa}}==
Ursa names are case sensitive:
<langsyntaxhighlight lang="ursa">> decl string dog Dog DOG
> set dog "Benjamin"
> set Dog "Samba"
Line 1,597 ⟶ 1,817:
> out "The three dogs are named " dog ", " Dog ", and " DOG endl console
The three dogs are named Benjamin, Samba, and Bernie
></langsyntaxhighlight>
 
=={{header|VBA}}==
VBA is case sensitive case insensitive. The variable names 'dog', 'Dog' and 'DOG' can not co-exist.
<langsyntaxhighlight lang="vb">Public Sub case_sensitivity()
'VBA does not allow variables that only differ in case
'The VBA IDE vbe will rename variable 'dog' to 'DOG'
Line 1,610 ⟶ 1,829:
DOG = "Bernie"
Debug.Print "There is just one dog named " & DOG
End Sub</langsyntaxhighlight>{{out}}
<pre>There is just one dog named Bernie</pre>
 
=={{header|Wren}}==
Identifiers in Wren are case sensitive.
<langsyntaxhighlight ecmascriptlang="wren">var dog = "Benjamin"
var Dog = "Samba"
var DOG = "Bernie"
System.print("The three dogs are named %(dog), %(Dog) and %(DOG).")</langsyntaxhighlight>
 
{{out}}
Line 1,625 ⟶ 1,843:
</pre>
 
=={{header|XBS}}==
In XBS variable names are case-sensitive.
<syntaxhighlight lang="xbs">set dog="Benjamin";
set DOG="Samba";
set Dog="Bernie";
log(`The three dogs are named {dog}, {DOG} and {Dog}.`);</syntaxhighlight>
{{out}}
<pre>
The three dogs are named Benjamin, Samba and Bernie.
</pre>
=={{header|XLISP}}==
XLISP is entirely case-insensitive. The user can decide whether to have the system print symbols, etc., in capitals or in lower case, by assigning to the variable <tt>*PRINT-CASE*</tt>.
<langsyntaxhighlight lang="xlisp">(SETQ DOG 'BENJAMIN)
(SETQ Dog 'SAMBA)
(SETQ dog 'BERNIE)
(DISPLAY `(THERE IS JUST ONE DOG NAMED ,DOG))</langsyntaxhighlight>
There is, in any event, only one dog.
<pre>(THERE IS JUST ONE DOG NAMED BERNIE)</pre>
 
=={{header|XPL0}}==
XPL0 is normally case-insensitive, so there is really just one dog named
Line 1,643 ⟶ 1,870:
Ascii and ASCII or CpuReg and CPUReg.
 
=={{header|Zig}}==
In Zig identifiers are case-sensitive.
 
<syntaxhighlight lang="zig">const std = @import("std");
=={{header|Yabasic}}==
Yabasic names are case sensitive:
<lang yabasic>
dog$ = "Benjamin"
Dog$ = "Samba"
DOG$ = "Bernie"
print "The three dogs are named ", dog$, ", ", Dog$, " and ", DOG$
end</lang>
 
pub fn main() void {
const dog = "Benjamin";
const Dog = "Samba";
const DOG = "Bernie";
 
std.debug.print("The three dogs are named {s}, {s}, and {s}.\n", .{ dog, Dog, DOG });
}</syntaxhighlight>
 
{{out}}
<pre>
The three dogs are named Benjamin, Samba, and Bernie.
</pre>
 
=={{header|zkl}}==
<langsyntaxhighlight lang="zkl">var dog = "Benjamin", Dog = "Samba", DOG = "Bernie";</langsyntaxhighlight>
{{out}}
<pre>
Line 1,661 ⟶ 1,895:
L(L("DOG","Bernie"),L("Dog","Samba"),L("dog","Benjamin"))
</pre>
{{omit from|360 Assembly}}
 
{{omit from|6502 Assembly|Depends on assembler. Some have a -nocase command line argument that ignores sensitivity of labels.}}
{{omit from|8051 Assembly}}
{{omit from|8080 Assembly}}
{{omit from|8086 Assembly}}
{{omit from|68000 Assembly}}
{{omit from|AArch64 Assembly}}
{{omit from|ARM Assembly}}
{{omit from|MIPS Assembly}}
{{omit from|sed|No variables.}}
{{omit from|x86 Assembly}}
 
{{omit from|Z80 Assembly}}
=={{header|ZX Spectrum Basic}}==
<lang basic>10 LET D$="Benjamin"
20 PRINT "There is just one dog named ";d$</lang>
28

edits