Content deleted Content added
m →Other types: cell templates, {{code}} |
m →Functions: {{codett}} |
||
(15 intermediate revisions by the same user not shown) | |||
Line 34:
|-
| [[Ada (programming language)|Ada]]<ref name="Ada_RM_2012">Ada Reference Manual – Language and Standard Libraries; ISO/IEC 8652:201x (E), {{cite web |url=http://www.ada-auth.org/standards/12rm/RM-Final.pdf |title=Reference Manual |access-date=2013-07-19 |url-status=dead |archive-url=https://web.archive.org/web/20110427190723/http://www.ada-auth.org/standards/12rm/RM-Final.pdf |archive-date=2011-04-27 }}</ref>
|
|
|
|
|
|
|
|
| <code>Integer</code>{{ref|Ada_range|[j]}}
|
| {{n/a}}
|-
Line 288:
|-
| [[Fortran]]
|
| {{n/a}}
|
| {{n/a}}
|
| {{n/a}}
|
| {{n/a}}
|
Line 491:
* {{note|Cobol|h}} [[COBOL]] allows the specification of a required precision and will automatically select an available type capable of representing the specified precision. "<code>PIC S9999</code>", for example, would require a signed variable of four decimal digits precision. If specified as a binary field, this would select a 16-bit signed type on most platforms.
* {{note|Smalltalk|i}} [[Smalltalk]] automatically chooses an appropriate representation for integral numbers. Typically, two representations are present, one for integers fitting the native word size minus any tag bit ({{mono|SmallInteger}}) and one supporting arbitrary sized integers ({{mono|LargeInteger}}). Arithmetic operations support polymorphic arguments and return the result in the most appropriate compact representation.
* {{note|Ada_range|j}} [[Ada (programming language)|Ada]] range types are checked for boundary violations at run-time (as well as at compile-time for static expressions). Run-time boundary violations raise a "constraint error" exception. Ranges are not restricted to powers of two. Commonly predefined Integer subtypes are: Positive (
* {{note|Ada mod|k}} [[Ada (programming language)|Ada]] modulo types implement modulo arithmetic in all operations, i.e. no range violations are possible. Modulos are not restricted to powers of two.
* {{note|Scala char|l}} Commonly used for characters like Java's char.
Line 981:
| rowspan=3| <code>Boolean</code>
| rowspan=3| <code>Enum ''name''<br/>{{Spaces|3}}''item{{sub|1}}'' «= ''value''»<br/>{{Spaces|3}}''item{{sub|2}}'' «= ''value»<br/>{{Spaces|3}}...''<br/>End Enum</code>
|
|-
| [[Visual Basic .NET]]
Line 996:
| <code>bool</code>
| {{pre|1=
{{codett|2=python|
{{codett|2=python|class Name(enum.Enum):}}
''item{{sub|1}}'' = ''value''
''item{{sub|2}}'' = ''value''
Line 1,335:
|- valign="top"
| [[Haskell]] ([[Glasgow Haskell Compiler|GHC]])
| <code>{{codett|2=haskell|1=x = Array.array (0,}} ''size''-1) ''list_of_association_pairs''</code>
| <code>{{codett|2=haskell|1=x = Array.array ((0, 0,}}''...''), (''size<sub>1</sub>''-1, ''size<sub>2</sub>''-1,''...'')) ''list_of_association_pairs''</code>
|
|
Line 1,343:
| <code>''level-number type'' OCCURS ''size'' «TIMES».</code>
| {{em|one-dimensional array definition...}}
| <code>''level-number type'' OCCURS ''min-size'' TO ''max-size'' {{codett|2=cobolfree|1=«TIMES» DEPENDING «ON»}} ''size''.</code>{{ref|COBOL DEPENDING ON clause|[e]}}
| {{n/a}}
|}
Line 1,427:
|-
| [[Common Lisp]]
| {{code|2=lisp|(defstruct name slot-name (slot-name initial-value) (slot-name initial-value :type type) ...)
| rowspan=3| <code>(cons ''val{{sub|1}} val{{sub|2}}'')</code>{{ref|pair only|[c]}}
|
Line 1,545:
{| class="wikitable sortable"
!
!
! constant
! type synonym
Line 1,665:
** <code>Option Strict</code> is off and <code>initial_value</code> has a narrowing conversion to <code>final_type</code>.
If <code>Option Explicit</code> is off, variables do not require explicit declaration; they are declared implicitly when used:
<
| <code>Imports ''synonym'' = ''type''</code>
|-
Line 1,760:
* {{note|variable types|b}}Types are just regular objects, so you can just assign them.
* {{note|Perl's my keyword|c}} In Perl, the "my" keyword scopes the variable into the block.
* {{note|ML ref|d}} Technically, this does not declare ''name'' to be a mutable variable—in ML, all names can only be bound once; rather, it declares ''name'' to point to a "reference" data structure, which is a simple mutable cell. The data structure can then be read and written to using the <code>!</code> and <
* {{note|Ada declaration|e}} If no initial value is given, an invalid value is automatically assigned (which will trigger a run-time exception if it used before a valid value has been assigned). While this behaviour can be suppressed it is recommended in the interest of predictability. If no invalid value can be found for a type (for example in case of an unconstraint integer type), a valid, yet predictable value is chosen instead.
* {{note|Rust declaration|f}} In Rust, if no initial value is given to a <code>let</code> or <code>let mut</code> variable and it is never assigned to later, there is an [https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#unused-variables "unused variable" warning]. If no value is provided for a <code>const</code> or <code>static</code> or <code>static mut</code> variable, there is an error. There is a [https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html?#non-upper-case-globals "non-upper-case globals"] error for non-uppercase <code>const</code> variables. After it is defined, a <code>static mut</code> variable can only be assigned to in an <code>unsafe</code> block or function.
Line 2,074:
| <code>while ''condition'' { ''instructions'' }</code>
| 2.x:<br/><code>repeat { ''instructions'' } while ''condition''</code><br/>1.x:<br/><code>do { ''instructions'' } while ''condition''</code>
| <code>for ''i'' = ''first'' ... ''last'' { ''instructions'' }</code><br/>or<br/><code>for ''i'' = ''first'' ..< ''last
| <code>for ''item'' in ''set'' { ''instructions'' }</code>
|-
Line 2,116:
| <code>(loop{{indent|2}}while ''condition''{{indent|2}}do{{indent|2}}''instructions'')</code><br/>or<br/><code>(do () (''notcondition''){{indent|2}}''instructions'')</code>
| <code>(loop{{indent|2}}do{{indent|2}}''instructions''{{indent|2}}while ''condition'')</code>
| <code>(loop{{indent|2}}for i from ''first'' to ''last «by 1»''{{indent|2}}do{{indent|2}}''instructions'')</code><br/>or<br/><code>(dotimes (i N){{indent|2}}''instructions'')</code><br/>or<br/><code>(do ((i ''first'' {{codett|2=lisp|1=(1+ i))) ((>=i}} ''last''))<br/>{{indent|2}}''instructions'')</code>
| <code>(loop{{indent|2}}for ''item'' in ''list''{{indent|2}}do{{indent|2}}''instructions'')</code><br/>or<br/><code>(loop{{indent|2}}for ''item'' across ''vector''{{indent|2}}do{{indent|2}}''instructions'')</code><br/>or<br/><code>(dolist (''item list''){{indent|2}}''instructions'')</code><br/>or<br/><code>(mapc ''function list'')</code><br/>or<br/><code>(map ''type function sequence'')</code>
|-
| [[Scheme (programming language)|Scheme]]
| <code>(do () (''notcondition'') ''instructions'')</code><br/>or<br/><code>{{codett|2=scheme|(let loop () (if}} ''condition'' (begin ''instructions'' (loop))))</code>
| <code>{{codett|2=scheme|(let loop () (}}''instructions'' (if ''condition'' (loop))))</code>
| <code>(do ((i ''first'' {{codett|2=scheme|1=(+ i 1))) ((>= i}} ''last'')) ''instructions'')</code><br/>or<br/><code>{{codett|2=scheme|(let loop ((i}} ''first''{{codett|2=scheme|1)) (if (< i}} ''last'') (begin ''instructions'' {{codett|2=scheme|(loop (+ i 1)))))}}</code>
| <code>{{codett|2=scheme|(for-each (lambda (}}''item'') ''instructions'') ''list'')</code>
|-
| [[ISLISP]]
| <code>(while ''condition instructions'')</code>
| <code>{{codett|2=lisp|1=(tagbody loop}} ''instructions'' (if ''condition'' {{codett|2=lisp|1=(go loop))}}</code>
| <code>{{codett|2=lisp|1=(for ((i}} ''first'' {{codett|2=lisp|1=(+ i 1))) ((>= i}} ''last'')) ''instructions'')</code>
| <code>{{codett|2=lisp|1=(mapc (lambda (}}''item'') ''instructions'') ''list'')</code>
|-
| [[Pascal (programming language)|Pascal]]
Line 2,208:
|-
| [[COBOL]]
| <code>PERFORM ''procedure-1'' «THROUGH ''procedure-2''» ««WITH» TEST BEFORE» UNTIL ''condition''</code>{{ref|COBOL THRU|[c]}}<br/>or<br/><code>{{codett|2=cobolfree|PERFORM ««WITH» TEST BEFORE» UNTIL}} ''condition''{{indent|2}}''expression''<br/>END-PERFORM</code>
| <code>PERFORM ''procedure-1'' «THROUGH ''procedure-2''» «WITH» TEST AFTER UNTIL ''condition''</code>{{ref|COBOL THRU|[c]}}<br/>or<br/><code>{{codett|2=cobolfree|PERFORM «WITH» TEST AFTER UNTIL}} ''condition''{{indent|2}}''expression''<br/>END-PERFORM</code>
| <code>PERFORM ''procedure-1'' «THROUGH ''procedure-2»'' VARYING ''i'' FROM ''first'' BY ''increment'' UNTIL ''i'' > ''last''</code>{{ref|COBOL GREATER THAN|[d]}}<br/>or<br/><code>PERFORM VARYING ''i'' FROM ''first'' BY ''increment'' UNTIL ''i'' > ''last''{{indent|2}}''expression''<br/>END-PERFORM</code>{{ref|COBOL GREATER THAN|[d]}}
| {{n/a}}
Line 2,221:
* {{note|step|a}} "<code>step</code> n" is used to change the loop interval. If "<code>step</code>" is omitted, then the loop interval is 1.
* {{note|Ada_quantifiers|b}} This implements the [[universal quantifier]] ("for all" or
* {{note|COBOL THRU|c}} <code>THRU</code> may be used instead of <code>THROUGH</code>.
* {{note|COBOL GREATER THAN|d}}
* {{note|Rust FOREACH|e}} Type of set expression must implement trait <code>std::iter::IntoIterator</code>.
Line 2,238:
| <code>raise ''exception_name'' «with ''string_expression»''</code>
| <code>begin{{indent|2}}''statements''<br/>exception{{indent|2}}when ''exception_list<sub>1</sub>'' <nowiki>=></nowiki> ''statements;''{{indent|2}}when ''exception_list<sub>2</sub>'' <nowiki>=></nowiki> ''statements;''<br/>''...''{{indent|2}}«when others <nowiki>=></nowiki> ''statements;''»<br/>end</code>{{ref|Ada_uncaught_exceptions|[b]}}
| <code>{{codett|2=ada|1=pragma Assert}} («Check <nowiki>=></nowiki>» ''boolean_expression'' ««Message =>» ''string_expression''»)<br/>''[function {{pipe}} procedure {{pipe}} entry]'' with{{indent|2}}Pre <nowiki>=></nowiki> ''boolean_expression''{{indent|2}}Post <nowiki>=></nowiki> ''boolean_expression''<br/>''any_type'' with Type_Invariant <nowiki>=></nowiki> ''boolean_expression''</code>
|-
| [[APL (programming language)|APL]]
| <code>''«string_expression»'' ⎕SIGNAL ''number_expression''</code>
| <code>:Trap ''number«s»_expression''{{indent|2}}''statements''<br/>«:Case ''number«s»_expression''{{indent|2}}''statements''»<br/>''...''<br/>«:Else ''number«s»_expression''{{indent|2}}''statements''»<br/>:EndTrap</code>
| <code>''«string_expression»'' {{codett|⎕SIGNAL 98/⍨~|apl}}''condition''</code>
|-
| [[C (programming language)|C]] ([[C99]])
Line 2,280:
| [[Windows PowerShell]]
| <code>trap «[''exception'']» { ''instructions'' } ''... instructions''</code><br/>or<br/><code>try { ''instructions'' } catch «[''exception'']» { ''instructions'' } ''...'' «finally { ''instructions'' }»</code>
| <code>{{codett|[Debug]::Assert(|ps1}}''condition'')</code>
|-
| [[Objective-C]]
Line 2,294:
| [[Perl]]
| rowspan=2| <code>die ''exception'';</code>
| <code>eval { ''instructions'' {{codett|}; if ($@) {|perl}} ''instructions'' }</code>
| {{dunno}}
|-
Line 2,333:
| [[Visual Basic (classic)|Visual Basic]]
| <code>Err.Raise ''ERRORNUMBER''</code>
| <code>{{codett|2=vbnet|With New}} ''Try''{{codett|2=vbnet|: On Error Resume Next}}{{indent|2}}''OneInstruction<br/>.Catch''{{codett|2=vbnet|: On Error GoTo 0: Select Case}} ''.Number''{{indent|2}}Case ''SOME_ERRORNUMBER''{{indent|4}}''instructions''<br/>{{codett|2=vbnet|End Select: End With}}</code><syntaxhighlight lang="vbnet">
'*** Try class ***
Private mstrDescription As String
Line 2,355:
| <code>Throw ''exception''</code><br/>or<br/><code>Error ''errorcode''</code>
| <code>Try{{indent|2}}''instructions''<br/>Catch« ''name'' As ''exception''»« When ''condition''»{{indent|2}}''instructions''<br/>''...''<br/>«Finally{{indent|2}}''instructions''»<br/>End Try</code>
| <code>System.Diagnostics.<wbr/
|-
| [[Xojo]]
Line 2,394:
|-
| [[COBOL]]
| <code>{{codett|2=cobolfree|RAISE «EXCEPTION»}} ''exception''</code>
| <code>{{codett|2=cobolfree|USE «AFTER» EXCEPTION OBJECT}} ''class-name''.</code><br/>or<br/><code>{{codett|2=cobolfree|USE «AFTER» EO}} ''class-name''.</code><br/>or<br/><code>{{codett|2=cobolfree|USE «AFTER» EXCEPTION CONDITION}} ''exception-name'' «FILE ''file-name»''.</code><br/>or<br/><code>{{codett|2=cobolfree|USE «AFTER» EC}} ''exception-name'' «FILE ''file-name»''.</code>
| {{n/a}}
|-
Line 2,636:
| rowspan="5" | <code>[[void type|void]] ''foo''(''«parameters»'') { ''instructions'' }</code>
| rowspan="5" | <code>''type'' ''foo''(''«parameters»'') { ''instructions ...'' return ''value''; }</code>
| rowspan=3| <code>''«global declarations»''<br/>{{codett|2=c|int main(«int argc, char *argv[]»)}} { {{indent|2}}''instructions''<br/>}</code>
|- valign="top"
| [[Objective-C]]
Line 2,643:
|- valign="top"
| [[Java (programming language)|Java]]
| <code>{{codett|2=java|public static void main(String[] args)}} { ''instructions'' }</code><br/>or<br/><code>{{codett|2=java|public static void main(String}}[[variadic function|...]] args) { ''instructions'' }</code>
|- valign="top"
| [[D (programming language)|D]]
| <code>{{codett|2=d|int main(«char[][] args»)}} { ''instructions''}</code><br/>or<br/><code>{{codett|2=d|int main(«string[] args»)}} { ''instructions''}</code><br/>or<br/><code>{{codett|2=d|void main(«char[][] args»)}} { ''instructions''}</code><br/>or<br/><code>{{codett|2=d|void main(«string[] args»)}} { ''instructions''}</code>
|- valign="top"
| [[C Sharp (programming language)|C#]]
Line 2,653:
| Same as above; alternatively, if simple enough to be an expression:
<code>[[void type|void]] foo(''«parameters»'') => ''expression'';</code>
|
|- valign="top"
| [[JavaScript]]
| <code>function foo(''«parameters»'') { ''instructions'' }</code><br/>or<br/><code>{{codett|2=javascript|1=var foo = function (}}''«parameters»'') { ''instructions'' }</code><br/>or<br/><code>{{codett|2=javascript|1=var foo = new Function (}}''"«parameter»"'', ''...'', ''"«last parameter»"'' "''instructions''");</code>
| <code>function foo(''«parameters»'') { ''instructions ...'' return ''value''; }</code>
| {{n/a}}
Line 2,672:
| [[Common Lisp]]
| rowspan=3| <code>(foo ''«parameters»'')</code>
| <code>([[defun]] foo (''«parameters»''){{indent|2}}''instructions'')</code><br/>or<br/><code>{{codett|2=lisp|1=(setf (symbol-function
| <code>([[defun]] foo (''«parameters»''){{indent|2}}''...{{indent|2}}value'')</code>
| rowspan=3 {{n/a}}
Line 2,699:
| rowspan=2| Same as above; alternatively:
<code>Function Foo«(''parameters'')»« As ''type»''{{indent|2}}''instructions''{{indent|2}}Return ''value''<br/>End Function</code><br/>The <code>As</code> clause is not required if <code>Option Strict</code> is off. A type character may be used instead of the <code>As</code> clause.<br/>If control exits the function without a return value having been explicitly specified, the function returns the default value for the return type.
| rowspan=2| <code>{{codett|2=vbnet|Sub Main(««ByVal »args() As String»)}}{{indent|2}}''instructions''<br/>End Sub</code>or<br/><code>{{codett|2=vbnet|Function Main(««ByVal »args() As String») As Integer}}{{indent|2}}''instructions''<br/>End Function</code>
|- valign="top"
| [[Xojo]]
Line 2,723:
| [[Forth (programming language)|Forth]]
| <code>''«parameters» ''FOO</code>
| <code>{{codett|2=forth|: FOO « stack effect comment:}} ('' before'' -- ) »{{indent|2}}''instructions''<br/>;</code>
| <code>{{codett|2=forth|: FOO « stack effect comment:}} ('' before'' -- ''after'' ) »{{indent|2}}''instructions''<br/>;</code>
| {{n/a}}
|- valign="top"
Line 2,735:
| [[Perl]]
| <code>foo(''«parameters»'')</code><br/>or<br/><code>&foo«(''parameters'')»</code>
| <code>{{codett|2=perl|sub foo { «my (}}''parameters'') = @_;» ''instructions ''}</code>
| <code>{{codett|2=perl|sub foo { «my (}}''parameters'') = @_;» ''instructions''... «return» ''value''; }</code>
|- valign="top"
| [[Raku (programming language)|Raku]]
| <code>foo(''«parameters»'')</code><br/>or<br/><code>&foo«(''parameters'')»</code>
| <code>{{codett|2=raku|«multi »sub foo(}}''parameters'') { ''instructions'' }</code>
| <code>«our «''
|- valign="top"
| [[Ruby (programming language)|Ruby]]
Line 2,758:
| <code>def ''foo''«(''parameters'')»«: Unit =» { ''instructions'' }</code>
| <code>def ''foo''«(''parameters'')»«: ''type»'' = { ''instructions ...'' «return» ''value'' }</code>
| <code>{{codett|2=scala|1=def main(args: Array[String])}} { ''instructions'' }</code>
|- valign="top"
| [[Windows PowerShell]]
Line 2,785:
|- valign="top"
| [[F Sharp (programming language)|F#]]
| <code>{{codett|2=f#|[<EntryPoint>] let main args}} ='' instructions''</code>
|- valign="top"
| [[Standard ML]]
Line 2,805:
| rowspan=2| [[CoffeeScript]]
| <code>foo()</code>
|
| <code>{{codett|2=coffeescript|1=foo =
| rowspan=2 {{n/a}}
|- valign="top"
| <code>foo ''parameters''</code>
|
| <code>foo = ( ''parameters'' ) <nowiki>-></nowiki> ''value''</code>
|- valign="top"
Line 2,879:
| <code>''long'' = [''string'' longLongValue];</code>
| <code>''float'' = [''string'' doubleValue];</code>
| <code>''string'' = {{codett|2=objc|[NSString stringWithFormat
| <code>''string'' = {{codett|2=objc|[NSString stringWithFormat
|-
| [[C++]] (STL)
Line 3,046:
|-
| [[COBOL]]
| colspan=3 | <code>{{codett|2=cobolfree|MOVE «FUNCTION» NUMVAL(}}''string''){{ref|COBOL's NUMVAL alternatives|[c]}} TO ''number''</code>
| colspan=2 | <code>MOVE ''number'' TO ''numeric-edited''</code>
|-
Line 3,108:
|-
| [[Java (programming language)|Java]]
| <
| <code>System.out.print(''x'');</code><br/>or<br/><code>System.out.[[printf]](''format'', ''x'');</code><br/>or<br/><code>System.out.println(''x'');</code>
| <code>System.err.print(''x'');</code><br/>or<br/><code>System.err.[[printf]](''format'', ''x'');</code><br/>or<br/><code>System.err.println(''x'');</code>
|-
| [[Go (programming language)|Go]]
| <code>fmt.Scan(&''x'')</code><br/>or<br/><code>fmt.[[Scanf]](''format'', &''x'')</code><br/>or<br/><
| <code>fmt.Println(''x'')</code><br/>or<br/><code>fmt.[[Printf]](''format'', ''x'')</code>
| <code>fmt.Fprintln(os{{Not a typo|.}}Stderr, x)</code><br/>or<br/><code>fmt.[[Fprintf]](os{{Not a typo|.}}Stderr, ''format'', ''x'')</code>
Line 3,138:
|-
| [[Common Lisp]]
| <
| <code>(princ ''x'')</code><br/>or<br/><code>(format t ''format x'')</code>
| <
|-
| [[Scheme (programming language)|Scheme]] ([[R6RS|R<sup>6</sup>RS]])
| <
| <code>(display ''x'')</code><br/>or<br/><code>{{codett|(format #t|scheme}} ''format x'')</code>
| <
|-
| [[ISLISP]]
Line 3,208:
|-
| [[Raku (programming language)|Raku]]
| <
| <code>''x''.print</code><br/>or<br/><code>''x''.say</code>
| <code>''x''.note</code><br/>or<br/><
|-
| [[Ruby (programming language)|Ruby]]
Line 3,218:
|-
| [[Windows PowerShell]]
| <code>''$x'' = Read-Host«« -Prompt» ''text''»;</code><br/>or<br/><
| <code>''x'';</code><br/>or<br/><code>Write-Output ''x'';</code><br/>or<br/><code>echo ''x''</code>
| <code>Write-Error ''x''</code>
Line 3,228:
|-
| [[F Sharp (programming language)|F#]]
| <
| <code>[[printf]] ''format x ...''</code><br/>or<br/><code>[[printf]]n ''format x ...''</code>
| <code>[[fprintf|eprintf]] ''format x ...''</code><br/>or<br/><code>[[fprintf|eprintf]]n ''format x ...''</code>
|-
| [[Standard ML]]
| <
| <code>print ''str''</code>
| <code>{{codett|TextIO.output (TextIO.stdErr,|sml}}'' str'')</code>
Line 3,301:
| [[Rust (programming language)|Rust]]{{ref|Rust args|[a]}}
| <code>std::env::args().nth(''n'')</code><br/><code>std::env::args_os().nth(''n'')</code>
|
|
|-
| [[Swift (programming language)|Swift]]
Line 3,315:
|-
| [[Scheme (programming language)|Scheme]] ([[R6RS|R<sup>6</sup>RS]])
|
|
| first argument
|-
Line 3,337:
| <code>CmdArgs(''n'')</code>
| <code>CmdArgs.Length</code>
|
|-
| [[Xojo]]
Line 3,371:
| [[Perl]]
| <code>$ARGV[''n'']</code>
|
| <code>$0</code>
|-
| [[Raku (programming language)|Raku]]
| <code>@*ARGS[''n'']</code>
|
| <code>$PROGRAM_NAME</code>
|-
Line 3,437:
|-
| [[Objective-C]]
| <
|
|-
Line 3,505:
|-
| [[OCaml]]
| <code>Sys.command ''command
| <code>Unix.create_process ''prog args new_stdin new_stdout new_stderr, ...''</code>
| <code>Unix.execv ''prog args''</code><br/>or<br/><code>Unix.execve ''prog args env''</code>
Line 3,550:
|-
| [[Windows PowerShell]]
| <
| <code>«Invoke-Item »''program arg1 arg2 ...''</code>
|
|