Case-sensitivity of identifiers: Difference between revisions

Applesoft BASIC, and one BASIC to organize them all
(Add Cowgol)
(Applesoft BASIC, and one BASIC to organize them all)
Line 187:
 
The three dogs are named Benjamin, Samba and Bernie.
 
 
=={{header|BASIC}}==
==={{header|Applesoft BASIC}}===
{{works with|QBasic}}
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.
QBASIC is case-insensitive
<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>
<syntaxhighlight lang="basic256">DOG$ = "Benjamin"
{{out}}
DOG$ = "Samba"
<pre>There is just one dog named Bernie.
DOG$ = "Bernie"
</pre>
PRINT "There is just one dog, named "; DOG$</syntaxhighlight>
The Apple II and Apple II plus will convert all input characters to upper case.
=={{header|BASIC256}}==
<pre>THERE IS JUST ONE DOG NAMED BERNIE.
</pre>
 
==={{header|BASIC256}}===
BASIC256 is case-insensitive
<syntaxhighlight lang="basic256">dog = "Benjamin"
Line 201 ⟶ 207:
print "There is just one dog, named "; dog
end</syntaxhighlight>
 
==={{header|BBC BASIC}}===
<syntaxhighlight lang="bbcbasic"> dog$ = "Benjamin"
Dog$ = "Samba"
DOG$ = "Bernie"
PRINT "The three dogs are " dog$ ", " Dog$ " and " DOG$ "."</syntaxhighlight>
Output:
<pre>The three dogs are Benjamin, Samba and 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>
{{output}}
<pre>
There are three dogs named Benjamin, Samba and Bernie.
</pre>
 
==={{header|Liberty BASIC}}===
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>
The three dogs are Benjamin, Samba and Bernie.
 
==={{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|Run BASIC}}===
<syntaxhighlight lang="runbasic">
dog$ = "Benjamin"
doG$ = "Smokey"
Dog$ = "Samba"
DOG$ = "Bernie"
print "The 4 dogs are "; dog$; ", "; doG$; ", "; Dog$; " and "; DOG$; "."
</syntaxhighlight>
 
==={{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|Yabasic}}===
Yabasic names are case sensitive:
<syntaxhighlight lang="yabasic">
dog$ = "Benjamin"
Dog$ = "Samba"
DOG$ = "Bernie"
print "The three dogs are named ", dog$, ", ", Dog$, " and ", DOG$
end</syntaxhighlight>
 
==={{header|ZX Spectrum Basic}}===
<syntaxhighlight lang="basic">10 LET D$="Benjamin"
20 PRINT "There is just one dog named ";d$</syntaxhighlight>
 
 
 
=={{header|Batch File}}==
<syntaxhighlight lang="dos">
Line 216 ⟶ 319:
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>
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.
Line 587 ⟶ 684:
Output:
<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|Frink}}==
Frink is case-sensitive.
Line 610 ⟶ 690:
DOG = "Bernie"
println["There are three dogs named $dog, $Dog and $DOG"]</syntaxhighlight>
 
 
 
=={{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>
{{output}}
<pre>
There are three dogs named Benjamin, Samba and Bernie.
</pre>
 
 
 
Line 887 ⟶ 950:
<pre>3
Samba </pre>
=={{header|Liberty BASIC}}==
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>
The three dogs are Benjamin, Samba and Bernie.
=={{header|Logtalk}}==
 
Line 1,289 ⟶ 1,341:
 
</pre>
=={{header|PureBasic}}==
<syntaxhighlight lang="purebasic">dog$="Benjamin"
Dog$="Samba"
DOG$="Bernie"
Debug "There is just one dog named "+dog$</syntaxhighlight>
=={{header|Python}}==
Python variable names are case sensitive:
Line 1,490 ⟶ 1,537:
The constants are Dog, DOG.</pre>
 
 
=={{header|Run BASIC}}==
<syntaxhighlight lang="runbasic">
dog$ = "Benjamin"
doG$ = "Smokey"
Dog$ = "Samba"
DOG$ = "Bernie"
print "The 4 dogs are "; dog$; ", "; doG$; ", "; Dog$; " and "; DOG$; "."
</syntaxhighlight>
=={{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.
Line 1,666 ⟶ 1,706:
Which prints...
<pre>The three dogs are named Benjamin, 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|UNIX Shell}}==
<syntaxhighlight lang="sh">dog="Benjamin"
Line 1,740 ⟶ 1,772:
switch (/c) is to detect inconsistent capitalizing of names such as
Ascii and ASCII or CpuReg and CPUReg.
=={{header|Yabasic}}==
Yabasic names are case sensitive:
<syntaxhighlight lang="yabasic">
dog$ = "Benjamin"
Dog$ = "Samba"
DOG$ = "Bernie"
print "The three dogs are named ", dog$, ", ", Dog$, " and ", DOG$
end</syntaxhighlight>
=={{header|zkl}}==
<syntaxhighlight lang="zkl">var dog = "Benjamin", Dog = "Samba", DOG = "Bernie";</syntaxhighlight>
Line 1,755 ⟶ 1,779:
L(L("DOG","Bernie"),L("Dog","Samba"),L("dog","Benjamin"))
</pre>
=={{header|ZX Spectrum Basic}}==
<syntaxhighlight lang="basic">10 LET D$="Benjamin"
20 PRINT "There is just one dog named ";d$</syntaxhighlight>
{{omit from|360 Assembly}}
{{omit from|6502 Assembly|Depends on assembler. Some have a -nocase command line argument that ignores sensitivity of labels.}}
413

edits