Unicode variable names: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: update link to documentation) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 16: | Line 16: | ||
{{trans|Python}} |
{{trans|Python}} |
||
< |
<syntaxhighlight lang="11l">V Δx = 1 |
||
Δx++ |
Δx++ |
||
print(Δx)</ |
print(Δx)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 34: | Line 34: | ||
-- [http://8th-dev.com/local.html Writing localized applications with 8th] |
-- [http://8th-dev.com/local.html Writing localized applications with 8th] |
||
< |
<syntaxhighlight lang="forth"> |
||
1 var, Δ |
1 var, Δ |
||
Line 55: | Line 55: | ||
الوداع |
الوداع |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|ACL2}}== |
=={{header|ACL2}}== |
||
Variables in ACL2 cannot be modified in place. |
Variables in ACL2 cannot be modified in place. |
||
< |
<syntaxhighlight lang="lisp">(let ((Δ 1)) |
||
(1+ Δ))</ |
(1+ Δ))</syntaxhighlight> |
||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
As of Ada 2005, all source code can be made of up to 32bit characters. |
As of Ada 2005, all source code can be made of up to 32bit characters. |
||
Unless you have made it a default, GNAT would require the -gnatW8 flag to understand you are using UTF8 for the code below, other encodings are possible. |
Unless you have made it a default, GNAT would require the -gnatW8 flag to understand you are using UTF8 for the code below, other encodings are possible. |
||
< |
<syntaxhighlight lang="ada">with Ada.Text_IO; |
||
procedure main is |
procedure main is |
||
Δ : Integer; |
Δ : Integer; |
||
Line 72: | Line 72: | ||
Δ := Δ + 1; |
Δ := Δ + 1; |
||
Ada.Text_IO.Put_Line (Δ'Img); |
Ada.Text_IO.Put_Line (Δ'Img); |
||
end main;</ |
end main;</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> 42</pre> |
<pre> 42</pre> |
||
Line 109: | Line 109: | ||
In AppleScript, identifiers whose first and last characters are vertical bars (|) can contain any characters. The AppleScript Language Guide doesn't recommend their use as they can make scripts difficult to read, but they're perfectly legal. |
In AppleScript, identifiers whose first and last characters are vertical bars (|) can contain any characters. The AppleScript Language Guide doesn't recommend their use as they can make scripts difficult to read, but they're perfectly legal. |
||
< |
<syntaxhighlight lang="applescript">set |Δ| to 1 |
||
set |Δ| to |Δ| + 1 |
set |Δ| to |Δ| + 1 |
||
return |Δ|</ |
return |Δ|</syntaxhighlight> |
||
{{output}} |
{{output}} |
||
<lang |
<syntaxhighlight lang="applescript">2</syntaxhighlight> |
||
Vertical bars can also be used to differentiate between identifiers and reserved words should the need arise. The bars are just a signal to the compiler to accept what's between them as an identifier and aren't stored with the identifier itself. They may disappear once the code's compiled if the decompiler can't see a reason to include them. Or indeed they may be added if a script compiled on one machine is decompiled on another where one of the identifiers clashes with a term defined in a library or OSAX installed on that machine. |
Vertical bars can also be used to differentiate between identifiers and reserved words should the need arise. The bars are just a signal to the compiler to accept what's between them as an identifier and aren't stored with the identifier itself. They may disappear once the code's compiled if the decompiler can't see a reason to include them. Or indeed they may be added if a script compiled on one machine is decompiled on another where one of the identifiers clashes with a term defined in a library or OSAX installed on that machine. |
||
Line 124: | Line 124: | ||
However, you can set/get a variable with any name defined as a Unicode string, using the functions <code>let</code> (or its alias <code>:</code>) and <code>var</code>. |
However, you can set/get a variable with any name defined as a Unicode string, using the functions <code>let</code> (or its alias <code>:</code>) and <code>var</code>. |
||
< |
<syntaxhighlight lang="rebol">"Δ": 1 |
||
"Δ": inc var "Δ" |
"Δ": inc var "Δ" |
||
print ["Delta =>" var "Δ"]</ |
print ["Delta =>" var "Δ"]</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 137: | Line 137: | ||
Documentation: http://www.autohotkey.net/~Lexikos/AutoHotkey_L/docs/Variables.htm |
Documentation: http://www.autohotkey.net/~Lexikos/AutoHotkey_L/docs/Variables.htm |
||
{{works with|AutoHotkey_L}} |
{{works with|AutoHotkey_L}} |
||
< |
<syntaxhighlight lang="ahk">Δ = 1 |
||
Δ++ |
Δ++ |
||
MsgBox, % Δ</ |
MsgBox, % Δ</syntaxhighlight> |
||
=={{header|BaCon}}== |
=={{header|BaCon}}== |
||
This is a port from the C example. As mentioned there, C has limited support for Unicode variable names which is specified in the C standard, and BaCon, being a Basic-to-C converter, therefore has the same restrictions. The below example works with the CLang compiler. |
This is a port from the C example. As mentioned there, C has limited support for Unicode variable names which is specified in the C standard, and BaCon, being a Basic-to-C converter, therefore has the same restrictions. The below example works with the CLang compiler. |
||
< |
<syntaxhighlight lang="qbasic">PRAGMA COMPILER clang |
||
DECLARE Δ TYPE int |
DECLARE Δ TYPE int |
||
Line 151: | Line 151: | ||
INCR Δ |
INCR Δ |
||
PRINT Δ</ |
PRINT Δ</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 165: | Line 165: | ||
=={{header|Bracmat}}== |
=={{header|Bracmat}}== |
||
Bracmat allows any sequence of non-zero bytes as symbol and therefore, as variable name. Even the empty string is a variable, though a special one. If a symbol/variable name contains characters that have special meaning (operators, prefixes, parentheses, braces and the semicolon) it may be necessary to enclose it in quotes. Other special characters must be escaped C-style. See bracmat.html in the git-repo. The example below requires a terminal that supports UTF-8 encoded characters. |
Bracmat allows any sequence of non-zero bytes as symbol and therefore, as variable name. Even the empty string is a variable, though a special one. If a symbol/variable name contains characters that have special meaning (operators, prefixes, parentheses, braces and the semicolon) it may be necessary to enclose it in quotes. Other special characters must be escaped C-style. See bracmat.html in the git-repo. The example below requires a terminal that supports UTF-8 encoded characters. |
||
< |
<syntaxhighlight lang="bracmat">( (Δ=1) |
||
& 1+!Δ:?Δ |
& 1+!Δ:?Δ |
||
& out$("Δ:" !Δ) |
& out$("Δ:" !Δ) |
||
);</ |
);</syntaxhighlight> |
||
Output: |
Output: |
||
<pre>Δ: 2</pre> |
<pre>Δ: 2</pre> |
||
Line 177: | Line 177: | ||
Most modern compilers, as of 2020, support raw Unicode identifiers, given the file is encoded properly (typically UTF-8). |
Most modern compilers, as of 2020, support raw Unicode identifiers, given the file is encoded properly (typically UTF-8). |
||
< |
<syntaxhighlight lang="c">// Works for clang and GCC 10+ |
||
#include<stdio.h> |
#include<stdio.h> |
||
Line 185: | Line 185: | ||
printf("%d",Δ); |
printf("%d",Δ); |
||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |
||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 193: | Line 193: | ||
=={{header|C sharp|C#}}== |
=={{header|C sharp|C#}}== |
||
Section 2.4.2 of the [http://go.microsoft.com/fwlink/?LinkId=199552 C# Language Specification] gives rules for identifiers. They correspond exactly to those recommended by the [http://unicode.org/reports/tr31/ Unicode Standard Annex 31], except that underscore is allowed as an initial character (as is traditional in the C programming language), Unicode escape sequences are permitted in identifiers, and the "@" character is allowed as a prefix to enable keywords to be used as identifiers. |
Section 2.4.2 of the [http://go.microsoft.com/fwlink/?LinkId=199552 C# Language Specification] gives rules for identifiers. They correspond exactly to those recommended by the [http://unicode.org/reports/tr31/ Unicode Standard Annex 31], except that underscore is allowed as an initial character (as is traditional in the C programming language), Unicode escape sequences are permitted in identifiers, and the "@" character is allowed as a prefix to enable keywords to be used as identifiers. |
||
< |
<syntaxhighlight lang="csharp">class Program |
||
{ |
{ |
||
static void Main() |
static void Main() |
||
Line 201: | Line 201: | ||
System.Console.WriteLine(Δ); |
System.Console.WriteLine(Δ); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>2</pre> |
<pre>2</pre> |
||
Line 210: | Line 210: | ||
That being said, it is not currently enforced, so while you probably shouldn't, you technically can. |
That being said, it is not currently enforced, so while you probably shouldn't, you technically can. |
||
< |
<syntaxhighlight lang="clojure">(let [Δ 1] |
||
(inc Δ))</ |
(inc Δ))</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>2</pre> |
<pre>2</pre> |
||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
< |
<syntaxhighlight lang="lisp">(let ((Δ 1)) |
||
(incf Δ))</ |
(incf Δ))</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>2</pre> |
<pre>2</pre> |
||
=={{header|Crystal}}== |
=={{header|Crystal}}== |
||
< |
<syntaxhighlight lang="crystal">Δ = 1 |
||
Δ += 1 |
Δ += 1 |
||
puts Δ</ |
puts Δ</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>2</pre> |
<pre>2</pre> |
||
Line 230: | Line 230: | ||
=={{header|D}}== |
=={{header|D}}== |
||
D source files support four character encodings: ASCII, UTF-8, UTF-16 and UTF-32. |
D source files support four character encodings: ASCII, UTF-8, UTF-16 and UTF-32. |
||
< |
<syntaxhighlight lang="d">import std.stdio; |
||
void main() { |
void main() { |
||
Line 236: | Line 236: | ||
Δ++; |
Δ++; |
||
writeln(Δ); |
writeln(Δ); |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>2</pre> |
<pre>2</pre> |
||
Line 254: | Line 254: | ||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
For more information about naming identifiers (including variables) visit: [http://docwiki.embarcadero.com/RADStudio/en/Identifiers Identifiers in Delphi] |
For more information about naming identifiers (including variables) visit: [http://docwiki.embarcadero.com/RADStudio/en/Identifiers Identifiers in Delphi] |
||
< |
<syntaxhighlight lang="delphi">(* Compiled with Delphi XE *) |
||
program UnicodeVariableName; |
program UnicodeVariableName; |
||
Line 270: | Line 270: | ||
Writeln(Δ); |
Writeln(Δ); |
||
Readln; |
Readln; |
||
end.</ |
end.</syntaxhighlight> |
||
=={{header|DWScript}}== |
=={{header|DWScript}}== |
||
< |
<syntaxhighlight lang="delphi">var Δ : Integer; |
||
Δ := 1; |
Δ := 1; |
||
Inc(Δ); |
Inc(Δ); |
||
PrintLn(Δ);</ |
PrintLn(Δ);</syntaxhighlight> |
||
=={{header|Déjà Vu}}== |
=={{header|Déjà Vu}}== |
||
< |
<syntaxhighlight lang="dejavu">set :Δ 1 |
||
set :Δ ++ Δ |
set :Δ ++ Δ |
||
!. Δ</ |
!. Δ</syntaxhighlight> |
||
=={{header|EchoLisp}}== |
=={{header|EchoLisp}}== |
||
Symbol names can be any string including unicode characters. See the EchoLisp [http://www.echolalie.org/echolisp/help.html#language reference] documentation. |
Symbol names can be any string including unicode characters. See the EchoLisp [http://www.echolalie.org/echolisp/help.html#language reference] documentation. |
||
< |
<syntaxhighlight lang="lisp"> |
||
(define ∆-🍒 1) → ∆-🍒 |
(define ∆-🍒 1) → ∆-🍒 |
||
(set! ∆-🍒 (1+ ∆-🍒)) → 2 |
(set! ∆-🍒 (1+ ∆-🍒)) → 2 |
||
(printf "🔦 Look at ∆-🍒 : %d" ∆-🍒) |
(printf "🔦 Look at ∆-🍒 : %d" ∆-🍒) |
||
🔦 Look at ∆-🍒 : 2 |
🔦 Look at ∆-🍒 : 2 |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
ELENA 4.x: |
ELENA 4.x: |
||
< |
<syntaxhighlight lang="elena">public program() |
||
{ |
{ |
||
var Δ := 1; |
var Δ := 1; |
||
Line 301: | Line 301: | ||
console.writeLine:Δ |
console.writeLine:Δ |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Emacs Lisp}}== |
=={{header|Emacs Lisp}}== |
||
< |
<syntaxhighlight lang="lisp">(setq Δ 1) |
||
(setq Δ (1+ Δ)) |
(setq Δ (1+ Δ)) |
||
(message "Δ is %d" Δ)</ |
(message "Δ is %d" Δ)</syntaxhighlight> |
||
Variables are symbols and symbol names can be any string. Source code <code>.el</code> files can have all usual Emacs coding system specifications to give variables in non-ASCII. |
Variables are symbols and symbol names can be any string. Source code <code>.el</code> files can have all usual Emacs coding system specifications to give variables in non-ASCII. |
||
Line 314: | Line 314: | ||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |
||
As with C# the [http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/spec.html#_Toc207705761 F# Language Specification] refers to [http://www.unicode.org/reports/tr31/#Default_Identifier_Syntax Unicode Standard Annex #31] for identifier syntax, allowing Unicode letter characters. |
As with C# the [http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/spec.html#_Toc207705761 F# Language Specification] refers to [http://www.unicode.org/reports/tr31/#Default_Identifier_Syntax Unicode Standard Annex #31] for identifier syntax, allowing Unicode letter characters. |
||
< |
<syntaxhighlight lang="fsharp">let mutable Δ = 1 |
||
Δ <- Δ + 1 |
Δ <- Δ + 1 |
||
printfn "%d" Δ</ |
printfn "%d" Δ</syntaxhighlight> |
||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
Variable names can contain any character, inlcuding unicode characters, as long as they don't parse as a string or a number. |
Variable names can contain any character, inlcuding unicode characters, as long as they don't parse as a string or a number. |
||
< |
<syntaxhighlight lang="factor">USE: locals |
||
[let |
[let |
||
1 :> Δ! |
1 :> Δ! |
||
Δ 1 + Δ! |
Δ 1 + Δ! |
||
Δ . |
Δ . |
||
]</ |
]</syntaxhighlight> |
||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
Historically, Forth has worked only in ASCII (going so far as to reserve the eighth bit for symbol smudging), but modern implementations (e.g., Gforth) allow UTF-8 in word names, strings and comments. |
Historically, Forth has worked only in ASCII (going so far as to reserve the eighth bit for symbol smudging), but modern implementations (e.g., Gforth) allow UTF-8 in word names, strings and comments. |
||
< |
<syntaxhighlight lang="forth">variable ∆ |
||
1 ∆ ! |
1 ∆ ! |
||
1 ∆ +! |
1 ∆ +! |
||
∆ @ .</ |
∆ @ .</syntaxhighlight> |
||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
Line 343: | Line 343: | ||
If one wanted to use a Greek character such as Δ for a variable name, it would therefore have to be spelled out : |
If one wanted to use a Greek character such as Δ for a variable name, it would therefore have to be spelled out : |
||
< |
<syntaxhighlight lang="freebasic">'FB 1.05.0 Win64 |
||
Var delta = 1 |
Var delta = 1 |
||
delta += 1 |
delta += 1 |
||
Print delta '' 2 |
Print delta '' 2 |
||
Sleep</ |
Sleep</syntaxhighlight> |
||
=={{header|Frink}}== |
=={{header|Frink}}== |
||
Frink can use Unicode variable names that meet certain constraints. Variable names that don't meet these constraints can still be parsed and displayed by specifying them as Unicode escapes: [https://frinklang.org/#UnicodeInFrink Unicode Variable Names] |
Frink can use Unicode variable names that meet certain constraints. Variable names that don't meet these constraints can still be parsed and displayed by specifying them as Unicode escapes: [https://frinklang.org/#UnicodeInFrink Unicode Variable Names] |
||
< |
<syntaxhighlight lang="frink"> |
||
Δ = 1 |
Δ = 1 |
||
Δ = Δ + 1 |
Δ = Δ + 1 |
||
println[Δ] |
println[Δ] |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Go}}== |
=={{header|Go}}== |
||
Go source encoding is [http://golang.org/doc/go_spec.html#Source_code_representation specified] to be UTF-8. Allowable variable names are specified in the sections [http://golang.org/doc/go_spec.html#Identifiers identifiers] and [http://golang.org/doc/go_spec.html#Exported_identifiers Exported identifiers]. |
Go source encoding is [http://golang.org/doc/go_spec.html#Source_code_representation specified] to be UTF-8. Allowable variable names are specified in the sections [http://golang.org/doc/go_spec.html#Identifiers identifiers] and [http://golang.org/doc/go_spec.html#Exported_identifiers Exported identifiers]. |
||
< |
<syntaxhighlight lang="go">package main |
||
import "fmt" |
import "fmt" |
||
Line 368: | Line 368: | ||
Δ++ |
Δ++ |
||
fmt.Println(Δ) |
fmt.Println(Δ) |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 381: | Line 381: | ||
Also, Haskell does not allow mutable variables, so incrementing delta isn't possible. Instead lower case psi was used to store the incremented value of delta since tridents are cool. |
Also, Haskell does not allow mutable variables, so incrementing delta isn't possible. Instead lower case psi was used to store the incremented value of delta since tridents are cool. |
||
< |
<syntaxhighlight lang="haskell">main = print ψ |
||
where δΔ = 1 |
where δΔ = 1 |
||
ψ = δΔ + 1</ |
ψ = δΔ + 1</syntaxhighlight> |
||
=={{header|J}}== |
=={{header|J}}== |
||
Line 395: | Line 395: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
< |
<syntaxhighlight lang="java">int Δ = 1; |
||
double π = 3.141592; |
double π = 3.141592; |
||
String 你好 = "hello"; |
String 你好 = "hello"; |
||
Δ++; |
Δ++; |
||
System.out.println(Δ);</ |
System.out.println(Δ);</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 406: | Line 406: | ||
=={{header|JavaScript}}== |
=={{header|JavaScript}}== |
||
< |
<syntaxhighlight lang="javascript">var ᾩ = "something"; |
||
var ĦĔĽĻŎ = "hello"; |
var ĦĔĽĻŎ = "hello"; |
||
var 〱〱〱〱 = "too less"; |
var 〱〱〱〱 = "too less"; |
||
Line 412: | Line 412: | ||
var KingGeorgeⅦ = "Roman numerals."; |
var KingGeorgeⅦ = "Roman numerals."; |
||
console.log([ᾩ, ĦĔĽĻŎ, 〱〱〱〱, जावास्क्रिप्ट, KingGeorgeⅦ])</ |
console.log([ᾩ, ĦĔĽĻŎ, 〱〱〱〱, जावास्क्रिप्ट, KingGeorgeⅦ])</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 422: | Line 422: | ||
However, in practice, the keys of JSON objects can also be used as variable names. For example, in the following expression, "Δ" is in effect set to 1 and then its value is retrieved in the environment in which "Δ" has been set: |
However, in practice, the keys of JSON objects can also be used as variable names. For example, in the following expression, "Δ" is in effect set to 1 and then its value is retrieved in the environment in which "Δ" has been set: |
||
< |
<syntaxhighlight lang="jq">{ "Δ": 1 } | .["Δ"]</syntaxhighlight> |
||
In jq 1.5 and later, < |
In jq 1.5 and later, <syntaxhighlight lang="jq">.["Δ"]</syntaxhighlight> can be abbreviated to <syntaxhighlight lang="jq">."Δ"</syntaxhighlight> |
||
Strictly speaking, variables in jq cannot be incremented (in fact, strictly speaking, jq does not have variables at all), but the equivalent operation is illustrated here: |
Strictly speaking, variables in jq cannot be incremented (in fact, strictly speaking, jq does not have variables at all), but the equivalent operation is illustrated here: |
||
< |
<syntaxhighlight lang="jq">{ "Δ": 1 } # initialization |
||
| .["Δ"] += 1 # increment by 1 |
| .["Δ"] += 1 # increment by 1 |
||
| .["Δ"] # emit the incremented value</ |
| .["Δ"] # emit the incremented value</syntaxhighlight> |
||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
The Julia documentation on |
The Julia documentation on |
||
[http://docs.julialang.org/en/latest/manual/variables/#allowed-variable-names allowed variable names] explicitly describes the wide variety of Unicode codepoints that are allowed: |
[http://docs.julialang.org/en/latest/manual/variables/#allowed-variable-names allowed variable names] explicitly describes the wide variety of Unicode codepoints that are allowed: |
||
< |
<syntaxhighlight lang="julia">julia> Δ = 1 ; Δ += 1 ; Δ |
||
2</ |
2</syntaxhighlight> |
||
The allowed identifiers also include sub/superscripts and combining characters (e.g. accent marks): |
The allowed identifiers also include sub/superscripts and combining characters (e.g. accent marks): |
||
< |
<syntaxhighlight lang="julia">julia> Δ̂₂ = Δ^2 |
||
4</ |
4</syntaxhighlight> |
||
and the Julia interactive shells (and many editors) allow typing these symbols via tab-completion of their LaTeX abbreviations. |
and the Julia interactive shells (and many editors) allow typing these symbols via tab-completion of their LaTeX abbreviations. |
||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
< |
<syntaxhighlight lang="scala">fun main(args: Array<String>) { |
||
var Δ = 1 |
var Δ = 1 |
||
Δ++ |
Δ++ |
||
print(Δ) |
print(Δ) |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 455: | Line 455: | ||
=={{header|Lily}}== |
=={{header|Lily}}== |
||
< |
<syntaxhighlight lang="lily">var Δ = 1 |
||
Δ += 1 |
Δ += 1 |
||
print(Δ.to_s())</ |
print(Δ.to_s())</syntaxhighlight> |
||
=={{header|Lingo}}== |
=={{header|Lingo}}== |
||
Since version 11, in Lingo/Director both native strings and scripts use UTF-8 encoding. Variable names support Unicode characters: |
Since version 11, in Lingo/Director both native strings and scripts use UTF-8 encoding. Variable names support Unicode characters: |
||
< |
<syntaxhighlight lang="lingo">Δ = 1 |
||
Δ = Δ + 1 |
Δ = Δ + 1 |
||
put Δ |
put Δ |
||
-- 2</ |
-- 2</syntaxhighlight> |
||
=={{header|LiveCode}}== |
=={{header|LiveCode}}== |
||
In LiveCode 7+ all characters are stored as unicode. This includes variable (container) names, although it does not seem to state this in the LC dictionary. |
In LiveCode 7+ all characters are stored as unicode. This includes variable (container) names, although it does not seem to state this in the LC dictionary. |
||
< |
<syntaxhighlight lang="livecode">put 1 into Δ |
||
add 1 to Δ |
add 1 to Δ |
||
put Δ |
put Δ |
||
-- result is 2</ |
-- result is 2</syntaxhighlight> |
||
=={{header|LOLCODE}}== |
=={{header|LOLCODE}}== |
||
The [http://lolcode.com/specs/1.2#variables spec] mandates that identifiers be alphanumeric. However, the fact that [http://lolcode.com/specs/1.2#strings YARNs] are Unicode-aware permits the use of the [http://lolcode.com/proposals/1.3/bukkit2#srs-serious-cast SRS operator] introduced in 1.3 to utilize variables of arbitrary name. |
The [http://lolcode.com/specs/1.2#variables spec] mandates that identifiers be alphanumeric. However, the fact that [http://lolcode.com/specs/1.2#strings YARNs] are Unicode-aware permits the use of the [http://lolcode.com/proposals/1.3/bukkit2#srs-serious-cast SRS operator] introduced in 1.3 to utilize variables of arbitrary name. |
||
< |
<syntaxhighlight lang="lolcode">I HAS A SRS "Δ" ITZ 1 |
||
SRS "Δ" R SUM OF SRS ":(394)" AN 1 |
SRS "Δ" R SUM OF SRS ":(394)" AN 1 |
||
VISIBLE SRS ":[GREEK CAPITAL LETTER DELTA]"</ |
VISIBLE SRS ":[GREEK CAPITAL LETTER DELTA]"</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>2</pre> |
<pre>2</pre> |
||
Line 484: | Line 484: | ||
Lua 5.3 supports UTF-8 encoding as documented here: https://www.lua.org/manual/5.3/manual.html#6.5 . |
Lua 5.3 supports UTF-8 encoding as documented here: https://www.lua.org/manual/5.3/manual.html#6.5 . |
||
However, this support is not strictly necessary for this task so long as the Lua script is edited using a UTF-8 enabled text editor. |
However, this support is not strictly necessary for this task so long as the Lua script is edited using a UTF-8 enabled text editor. |
||
< |
<syntaxhighlight lang="lua">∆ = 1 |
||
∆ = ∆ + 1 |
∆ = ∆ + 1 |
||
print(∆)</ |
print(∆)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>2</pre> |
<pre>2</pre> |
||
Line 495: | Line 495: | ||
The language has Greek statements too |
The language has Greek statements too |
||
<syntaxhighlight lang="m2000 interpreter"> |
|||
<lang M2000 Interpreter> |
|||
Δ=1 |
Δ=1 |
||
Δ++ |
Δ++ |
||
Line 513: | Line 513: | ||
c͓͈̃͂̋̈̆̽h̥̪͕ͣ͛̊aͨͣ̍͞ơ̱͔̖͖̑̽ș̻̥ͬ̃̈ͩ =100 : Print "c͓͈̃͂̋̈̆̽h̥̪͕ͣ͛̊aͨͣ̍͞ơ̱͔̖͖̑̽ș̻̥ͬ̃̈ͩ ="; c͓͈̃͂̋̈̆̽h̥̪͕ͣ͛̊aͨͣ̍͞ơ̱͔̖͖̑̽ș̻̥ͬ̃̈ͩ |
c͓͈̃͂̋̈̆̽h̥̪͕ͣ͛̊aͨͣ̍͞ơ̱͔̖͖̑̽ș̻̥ͬ̃̈ͩ =100 : Print "c͓͈̃͂̋̈̆̽h̥̪͕ͣ͛̊aͨͣ̍͞ơ̱͔̖͖̑̽ș̻̥ͬ̃̈ͩ ="; c͓͈̃͂̋̈̆̽h̥̪͕ͣ͛̊aͨͣ̍͞ơ̱͔̖͖̑̽ș̻̥ͬ̃̈ͩ |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
||
< |
<syntaxhighlight lang="mathematica">Δ = 1; |
||
Δ++; |
Δ++; |
||
Print[Δ]</ |
Print[Δ]</syntaxhighlight> |
||
=={{header|Nemerle}}== |
=={{header|Nemerle}}== |
||
From the Nemerle [http://nemerle.org/wiki/index.php?title=Lexical_structure_%28ref%29 Reference Manual]: "Programs are written using the Unicode character set, using the UTF-8 encoding." |
From the Nemerle [http://nemerle.org/wiki/index.php?title=Lexical_structure_%28ref%29 Reference Manual]: "Programs are written using the Unicode character set, using the UTF-8 encoding." |
||
< |
<syntaxhighlight lang="nemerle">using System.Console; |
||
module UnicodeVar |
module UnicodeVar |
||
Line 532: | Line 532: | ||
WriteLine($"Δ = $Δ"); |
WriteLine($"Δ = $Δ"); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|NetRexx}}== |
=={{header|NetRexx}}== |
||
The ''NetRexx Language Definition'' section of the NetRexx documentation ([http://netrexx.org/files/nrl3.pdf netrexx.org/files/nrl3.pdf]) describes the character set support within the language. |
The ''NetRexx Language Definition'' section of the NetRexx documentation ([http://netrexx.org/files/nrl3.pdf netrexx.org/files/nrl3.pdf]) describes the character set support within the language. |
||
< |
<syntaxhighlight lang="netrexx">/* NetRexx */ |
||
options replace format comments java crossref symbols nobinary |
options replace format comments java crossref symbols nobinary |
||
Line 569: | Line 569: | ||
return |
return |
||
</syntaxhighlight> |
|||
</lang> |
|||
'''Output:''' |
'''Output:''' |
||
<pre> |
<pre> |
||
Line 584: | Line 584: | ||
From the spec: https://nim-lang.org/docs/manual.html#lexical-analysis-identifiers-amp-keywords |
From the spec: https://nim-lang.org/docs/manual.html#lexical-analysis-identifiers-amp-keywords |
||
< |
<syntaxhighlight lang="nimrod">var Δ = 1 |
||
inc Δ |
inc Δ |
||
echo Δ</ |
echo Δ</syntaxhighlight> |
||
=={{header|Objeck}}== |
=={{header|Objeck}}== |
||
As of 3.2, Objeck supports UTF-8 encoded I/O and stores characters in the runtime's native Unicode format. |
As of 3.2, Objeck supports UTF-8 encoded I/O and stores characters in the runtime's native Unicode format. |
||
< |
<syntaxhighlight lang="objeck"> |
||
class Test { |
class Test { |
||
function : Main(args : String[]) ~ Nil { |
function : Main(args : String[]) ~ Nil { |
||
Line 600: | Line 600: | ||
} |
} |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Ol}}== |
=={{header|Ol}}== |
||
Ol fully supports Unicode. |
Ol fully supports Unicode. |
||
< |
<syntaxhighlight lang="scheme"> |
||
(define Δ 1) |
(define Δ 1) |
||
(define Δ (+ Δ 1)) |
(define Δ (+ Δ 1)) |
||
(print Δ) |
(print Δ) |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
Line 626: | Line 626: | ||
2. |
2. |
||
< |
<syntaxhighlight lang="sgml"><@ LETVARLIT>Δ|1</@> |
||
<@ ACTICRVAR>Δ</@> |
<@ ACTICRVAR>Δ</@> |
||
<@ SAYVAR>Δ</@></ |
<@ SAYVAR>Δ</@></syntaxhighlight> |
||
Using what Google Translate says is the Traditional Chinese for 'delta' |
Using what Google Translate says is the Traditional Chinese for 'delta' |
||
< |
<syntaxhighlight lang="sgml"><@ LETVARLIT>三角洲|1</@> |
||
<@ ACTICRVAR>三角洲</@> |
<@ ACTICRVAR>三角洲</@> |
||
<@ SAYVAR>三角洲</@></ |
<@ SAYVAR>三角洲</@></syntaxhighlight> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
Requires Perl 5.8.1 at the minimum. See http://perldoc.perl.org/utf8.html |
Requires Perl 5.8.1 at the minimum. See http://perldoc.perl.org/utf8.html |
||
< |
<syntaxhighlight lang="perl">use utf8; |
||
my $Δ = 1; |
my $Δ = 1; |
||
$Δ++; |
$Δ++; |
||
print $Δ, "\n";</ |
print $Δ, "\n";</syntaxhighlight> |
||
<code>$</code> sigil can be omitted by using [http://perldoc.perl.org/perlsub.html#Lvalue-subroutines lvalue] subroutine: |
<code>$</code> sigil can be omitted by using [http://perldoc.perl.org/perlsub.html#Lvalue-subroutines lvalue] subroutine: |
||
< |
<syntaxhighlight lang="perl">use utf8; |
||
BEGIN { |
BEGIN { |
||
Line 656: | Line 656: | ||
Δ = 1; |
Δ = 1; |
||
Δ++; |
Δ++; |
||
print Δ, "\n";</ |
print Δ, "\n";</syntaxhighlight> |
||
or with Perl 5.10 and [http://perldoc.perl.org/functions/state.html state] modifier: |
or with Perl 5.10 and [http://perldoc.perl.org/functions/state.html state] modifier: |
||
< |
<syntaxhighlight lang="perl">use utf8; |
||
use v5.10; |
use v5.10; |
||
Line 669: | Line 669: | ||
Δ = 1; |
Δ = 1; |
||
Δ++; |
Δ++; |
||
say Δ;</ |
say Δ;</syntaxhighlight> |
||
One can have Unicode in identifier or subroutine names and also in package or class names. Use of Unicode for the last two purposes is, due to file and directory names, dependent on the filesystem. |
One can have Unicode in identifier or subroutine names and also in package or class names. Use of Unicode for the last two purposes is, due to file and directory names, dependent on the filesystem. |
||
Line 675: | Line 675: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
Phix does not officially support unicode variable names, however it took me less than 5 minutes (changes, which are now permanent, labelled with "for rosettacode/unicode" in ptok.e and pttree.e, setting charset and identset respectively) to get the following to work, as long as the source file is stored using utf8 with a proper BOM, as supported by Notepad and the included Edita. I will happily add further character ranges as required/requested: I simply don't know what those ranges are, but I believe that no code points in utf8 should overlap existing ascii chars such as +-* etc. |
Phix does not officially support unicode variable names, however it took me less than 5 minutes (changes, which are now permanent, labelled with "for rosettacode/unicode" in ptok.e and pttree.e, setting charset and identset respectively) to get the following to work, as long as the source file is stored using utf8 with a proper BOM, as supported by Notepad and the included Edita. I will happily add further character ranges as required/requested: I simply don't know what those ranges are, but I believe that no code points in utf8 should overlap existing ascii chars such as +-* etc. |
||
<!--< |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
||
<span style="color: #004080;">integer</span> <span style="color: #000000;">Δ</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span> |
<span style="color: #004080;">integer</span> <span style="color: #000000;">Δ</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span> |
||
<span style="color: #000000;">Δ</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span> |
<span style="color: #000000;">Δ</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span> |
||
<span style="color: #0000FF;">?</span><span style="color: #000000;">Δ</span> |
<span style="color: #0000FF;">?</span><span style="color: #000000;">Δ</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 692: | Line 692: | ||
Documentation: [http://php.net/manual/en/mbstring.php4.req.php mbstring.php4.req], [http://php.net/manual/en/language.variables.basics.php language.variables.basics] |
Documentation: [http://php.net/manual/en/mbstring.php4.req.php mbstring.php4.req], [http://php.net/manual/en/language.variables.basics.php language.variables.basics] |
||
< |
<syntaxhighlight lang="php"><?php |
||
$Δ = 1; |
$Δ = 1; |
||
++$Δ; |
++$Δ; |
||
echo $Δ;</ |
echo $Δ;</syntaxhighlight> |
||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
Variables are usually [http://software-lab.de/doc/ref.html#internal-io Internal Symbols], and their names may contain any UTF-8 character except null-bytes. White space, and 11 special characters (see the reference) must be escaped with a backslash. [http://software-lab.de/doc/ref.html#transient-io Transient Symbols] are often used as variables too, they follow the syntax of strings in other languages. |
Variables are usually [http://software-lab.de/doc/ref.html#internal-io Internal Symbols], and their names may contain any UTF-8 character except null-bytes. White space, and 11 special characters (see the reference) must be escaped with a backslash. [http://software-lab.de/doc/ref.html#transient-io Transient Symbols] are often used as variables too, they follow the syntax of strings in other languages. |
||
< |
<syntaxhighlight lang="picolisp">: (setq Δ 1) |
||
-> 1 |
-> 1 |
||
: Δ |
: Δ |
||
Line 706: | Line 706: | ||
-> 2 |
-> 2 |
||
: Δ |
: Δ |
||
-> 2</ |
-> 2</syntaxhighlight> |
||
=={{header|Pike}}== |
=={{header|Pike}}== |
||
<syntaxhighlight lang="pike"> |
|||
<lang Pike> |
|||
#charset utf8 |
#charset utf8 |
||
void main() |
void main() |
||
Line 717: | Line 717: | ||
write( Δ +"\n"); |
write( Δ +"\n"); |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{Out}} |
{{Out}} |
||
<pre> |
<pre> |
||
Line 724: | Line 724: | ||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |
||
<syntaxhighlight lang="powershell"> |
|||
<lang PowerShell> |
|||
$Δ = 2 |
$Δ = 2 |
||
$π = 3.14 |
$π = 3.14 |
||
$π*$Δ |
$π*$Δ |
||
</syntaxhighlight> |
|||
</lang> |
|||
<b>Output:</b> |
<b>Output:</b> |
||
<pre> |
<pre> |
||
Line 735: | Line 735: | ||
=={{header|Prolog}}== |
=={{header|Prolog}}== |
||
< |
<syntaxhighlight lang="prolog">% Unicode in predicate names: |
||
是. % be: means, approximately, "True". |
是. % be: means, approximately, "True". |
||
不是 :- \+ 是. % not be: means, approximately, "False". Defined as not 是. |
不是 :- \+ 是. % not be: means, approximately, "False". Defined as not 是. |
||
Line 745: | Line 745: | ||
% Call test2(1, Result) to have 2 assigned to Result. |
% Call test2(1, Result) to have 2 assigned to Result. |
||
test2(Δ, R) :- R is Δ + 1.</ |
test2(Δ, R) :- R is Δ + 1.</syntaxhighlight> |
||
Putting this into use: |
Putting this into use: |
||
< |
<syntaxhighlight lang="prolog">?- 是. |
||
true. |
true. |
||
Line 759: | Line 759: | ||
?- test2(1,Result). |
?- test2(1,Result). |
||
Result = 2.</ |
Result = 2.</syntaxhighlight> |
||
=={{header|Python}}== |
=={{header|Python}}== |
||
Line 767: | Line 767: | ||
Identifiers are unlimited in length. Case is significant. |
Identifiers are unlimited in length. Case is significant. |
||
< |
<syntaxhighlight lang="python">>>> Δx = 1 |
||
>>> Δx += 1 |
>>> Δx += 1 |
||
>>> print(Δx) |
>>> print(Δx) |
||
2 |
2 |
||
>>> </ |
>>> </syntaxhighlight> |
||
=={{header|R}}== |
=={{header|R}}== |
||
See <code>?assign</code> for details. |
See <code>?assign</code> for details. |
||
< |
<syntaxhighlight lang="rsplus">f <- function(`∆`=1) `∆`+1 |
||
f(1)</ |
f(1)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>[1] 2</pre> |
<pre>[1] 2</pre> |
||
Line 786: | Line 786: | ||
Racket has virtually no restrictions on valid characters for identifiers. In particular, Unicode identifiers are supported. |
Racket has virtually no restrictions on valid characters for identifiers. In particular, Unicode identifiers are supported. |
||
<syntaxhighlight lang="racket"> |
|||
<lang Racket> |
|||
#lang racket |
#lang racket |
||
Line 800: | Line 800: | ||
(printf "Δ = ~s\n" Δ) ; prints "Δ = 2" |
(printf "Δ = ~s\n" Δ) ; prints "Δ = 2" |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
Line 807: | Line 807: | ||
See the current Raku documentation on the topic here: https://docs.raku.org/language/syntax#Identifiers |
See the current Raku documentation on the topic here: https://docs.raku.org/language/syntax#Identifiers |
||
<lang |
<syntaxhighlight lang="raku" line>my $Δ = 1; |
||
$Δ++; |
$Δ++; |
||
say $Δ;</ |
say $Δ;</syntaxhighlight> |
||
Function and subroutine names can also use Unicode characters: (as can methods, classes, packages, whatever...) |
Function and subroutine names can also use Unicode characters: (as can methods, classes, packages, whatever...) |
||
<lang |
<syntaxhighlight lang="raku" line>my @ᐁ = (0, 45, 60, 90); |
||
sub π { pi }; |
sub π { pi }; |
||
Line 819: | Line 819: | ||
for @ᐁ -> $ಠ_ಠ { say sin $ಠ_ಠ° }; |
for @ᐁ -> $ಠ_ಠ { say sin $ಠ_ಠ° }; |
||
sub c͓͈̃͂̋̈̆̽h̥̪͕ͣ͛̊aͨͣ̍͞ơ̱͔̖͖̑̽ș̻̥ͬ̃̈ͩ { 'HE COMES' }</ |
sub c͓͈̃͂̋̈̆̽h̥̪͕ͣ͛̊aͨͣ̍͞ơ̱͔̖͖̑̽ș̻̥ͬ̃̈ͩ { 'HE COMES' }</syntaxhighlight> |
||
<br> |
<br> |
||
Line 826: | Line 826: | ||
=={{header|Retro}}== |
=={{header|Retro}}== |
||
< |
<syntaxhighlight lang="retro">'Δ var |
||
#1 !Δ |
#1 !Δ |
||
@Δ n:put |
@Δ n:put |
||
&Δ v:inc |
&Δ v:inc |
||
@Δ n:put</ |
@Δ n:put</syntaxhighlight> |
||
Function and variable names are stored as strings, and UTF-8 is usable, as long as the host system allows it. |
Function and variable names are stored as strings, and UTF-8 is usable, as long as the host system allows it. |
||
Line 842: | Line 842: | ||
This REXX program works because the '''R4''' and '''ROO''' REXX interpreters support an extended character set. |
This REXX program works because the '''R4''' and '''ROO''' REXX interpreters support an extended character set. |
||
< |
<syntaxhighlight lang="rexx">/*REXX program (using the R4 REXX interpreter) which uses a Greek delta char).*/ |
||
'chcp' 1253 "> NUL" /*ensure we're using correct code page.*/ |
'chcp' 1253 "> NUL" /*ensure we're using correct code page.*/ |
||
Δ=1 /*define delta (variable name Δ) to 1*/ |
Δ=1 /*define delta (variable name Δ) to 1*/ |
||
Δ=Δ+1 /*bump the delta REXX variable by unity*/ |
Δ=Δ+1 /*bump the delta REXX variable by unity*/ |
||
say 'Δ=' Δ /*stick a fork in it, we're all done. */</ |
say 'Δ=' Δ /*stick a fork in it, we're all done. */</syntaxhighlight> |
||
'''output''' |
'''output''' |
||
<pre> |
<pre> |
||
Line 853: | Line 853: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
< |
<syntaxhighlight lang="ring"> |
||
# Project : Unicode variable names |
# Project : Unicode variable names |
||
Δ = "Ring Programming Language" |
Δ = "Ring Programming Language" |
||
see Δ + nl |
see Δ + nl |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 866: | Line 866: | ||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
Ruby supports about 100 encodings, the default being UTF-8. |
Ruby supports about 100 encodings, the default being UTF-8. |
||
< |
<syntaxhighlight lang="ruby">Δ = 1 |
||
Δ += 1 |
Δ += 1 |
||
puts Δ # => 2</ |
puts Δ # => 2</syntaxhighlight> |
||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
Line 875: | Line 875: | ||
<b>Non-ASCII identifiers are [https://github.com/mozilla/rust/pull/10605 feature gated] since version 0.9</b> |
<b>Non-ASCII identifiers are [https://github.com/mozilla/rust/pull/10605 feature gated] since version 0.9</b> |
||
< |
<syntaxhighlight lang="rust">#![feature(non_ascii_idents)] |
||
#![allow(non_snake_case)] |
#![allow(non_snake_case)] |
||
Line 882: | Line 882: | ||
Δ += 1; |
Δ += 1; |
||
println!("{}", Δ); |
println!("{}", Δ); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|S-lang}}== |
=={{header|S-lang}}== |
||
Line 904: | Line 904: | ||
not just in variable but also function and reference names, and tested under |
not just in variable but also function and reference names, and tested under |
||
S-Lang versions 2.0.6 and pre2.3.1-23. |
S-Lang versions 2.0.6 and pre2.3.1-23. |
||
< |
<syntaxhighlight lang="s-lang">define ∆increment(∆ref) { |
||
@∆ref++; |
@∆ref++; |
||
} |
} |
||
Line 915: | Line 915: | ||
print(foo∆bar); |
print(foo∆bar); |
||
print(∆bar); |
print(∆bar); |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
2 |
2 |
||
Line 921: | Line 921: | ||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
< |
<syntaxhighlight lang="scala">var Δ = 1 |
||
val π = 3.141592 |
val π = 3.141592 |
||
val 你好 = "hello" |
val 你好 = "hello" |
||
Δ += 1 |
Δ += 1 |
||
println(Δ)</ |
println(Δ)</syntaxhighlight> |
||
=={{header|SenseTalk}}== |
=={{header|SenseTalk}}== |
||
< |
<syntaxhighlight lang="sensetalk">put 1 into Δ |
||
add 1 to Δ |
add 1 to Δ |
||
put Δ</ |
put Δ</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>2</pre> |
<pre>2</pre> |
||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
< |
<syntaxhighlight lang="ruby">var Δ = 1; |
||
Δ += 1; |
Δ += 1; |
||
say Δ;</ |
say Δ;</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>2</pre> |
<pre>2</pre> |
||
Line 945: | Line 945: | ||
Here is how to create a macro, a scalar and a Mata variable named Δ: |
Here is how to create a macro, a scalar and a Mata variable named Δ: |
||
< |
<syntaxhighlight lang="stata">sca Δ=10 |
||
sca Δ=Δ+1 |
sca Δ=Δ+1 |
||
di Δ |
di Δ |
||
Line 957: | Line 957: | ||
Δ++ |
Δ++ |
||
Δ |
Δ |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Swift}}== |
=={{header|Swift}}== |
||
< |
<syntaxhighlight lang="swift">var Δ = 1 |
||
let π = 3.141592 |
let π = 3.141592 |
||
let 你好 = "hello" |
let 你好 = "hello" |
||
Δ++ |
Δ++ |
||
println(Δ)</ |
println(Δ)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 972: | Line 972: | ||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
Tcl variable names can include any character <!-- but the <tt>::</tt> sequence is special — it is the namespace separator — and there are restrictions when parentheses are involved, as they are used for associative arrays; these are not matters that are in the spirit of this task though, so this is a comment! --> (the <code>$var</code> syntax can't, but that's just a shorthand for the operationally-equivalent <code>[set var]</code>). Also (in tcl 8.6, at least), the <code>${var}</code> syntax does work. Thus, this script is entirely legal: |
Tcl variable names can include any character <!-- but the <tt>::</tt> sequence is special — it is the namespace separator — and there are restrictions when parentheses are involved, as they are used for associative arrays; these are not matters that are in the spirit of this task though, so this is a comment! --> (the <code>$var</code> syntax can't, but that's just a shorthand for the operationally-equivalent <code>[set var]</code>). Also (in tcl 8.6, at least), the <code>${var}</code> syntax does work. Thus, this script is entirely legal: |
||
< |
<syntaxhighlight lang="tcl">set Δx 1 |
||
incr Δx |
incr Δx |
||
puts [set Δx] |
puts [set Δx] |
||
puts ${Δx}</ |
puts ${Δx}</syntaxhighlight> |
||
However, this script only works smoothly if the “<tt>Δ</tt>” character is in the system's default encoding (thankfully more common than it used to be, as more and more systems use UTF-8 or UTF-16 as their default encodings) so normal Tcl practice is to stick to ASCII for identifier names. |
However, this script only works smoothly if the “<tt>Δ</tt>” character is in the system's default encoding (thankfully more common than it used to be, as more and more systems use UTF-8 or UTF-16 as their default encodings) so normal Tcl practice is to stick to ASCII for identifier names. |
||
Line 982: | Line 982: | ||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |
||
{{works with|zsh}} |
{{works with|zsh}} |
||
< |
<syntaxhighlight lang="bash"> |
||
Δ=1 |
Δ=1 |
||
Δ=`expr $Δ + 1` |
Δ=`expr $Δ + 1` |
||
echo $Δ |
echo $Δ |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre>2</pre> |
<pre>2</pre> |
||
Line 999: | Line 999: | ||
{{works with|Visual Basic|5}} |
{{works with|Visual Basic|5}} |
||
{{works with|Visual Basic|6}} |
{{works with|Visual Basic|6}} |
||
< |
<syntaxhighlight lang="vb">Sub Main() |
||
Dim Δ As Integer |
Dim Δ As Integer |
||
Δ=1 |
Δ=1 |
||
Δ=Δ+1 |
Δ=Δ+1 |
||
Debug.Print Δ |
Debug.Print Δ |
||
End Sub</ |
End Sub</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>2</pre> |
<pre>2</pre> |
||
Line 1,014: | Line 1,014: | ||
The error description refers to the bytes in the UTF encoding of 'Δ' which can't appear (outside a string) in a Wren script. |
The error description refers to the bytes in the UTF encoding of 'Δ' which can't appear (outside a string) in a Wren script. |
||
< |
<syntaxhighlight lang="ecmascript">var a = 3 |
||
var b = 2 |
var b = 2 |
||
var delta = a - b // ok |
var delta = a - b // ok |
||
var Δ = delta // not ok</ |
var Δ = delta // not ok</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,027: | Line 1,027: | ||
=={{header|zkl}}== |
=={{header|zkl}}== |
||
The short answer is zkl identifiers are a small subset of ASCII. This is enforced by the compiler. That said, the VM doesn't particularly care about names (although UTF-8 will cause sorting/etc issues). So ... |
The short answer is zkl identifiers are a small subset of ASCII. This is enforced by the compiler. That said, the VM doesn't particularly care about names (although UTF-8 will cause sorting/etc issues). So ... |
||
< |
<syntaxhighlight lang="zkl">delta:="\U0394;"; // UTF-8 delta |
||
klass:= // embryo(names, numFcns, numClasses, numParents, ...) |
klass:= // embryo(names, numFcns, numClasses, numParents, ...) |
||
self.embryo(L("","",delta),0,0,0).cook(); |
self.embryo(L("","",delta),0,0,0).cook(); |
||
Line 1,035: | Line 1,035: | ||
dv:=klass.setVar(0); // which actually gets the var, go figure |
dv:=klass.setVar(0); // which actually gets the var, go figure |
||
dv.inc(); // ie (*ptr)++ |
dv.inc(); // ie (*ptr)++ |
||
dv.value.println();</ |
dv.value.println();</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |