Comparison of programming languages (basic instructions): Difference between revisions

Content deleted Content added
removed nowiki tags where unnecessary
fixed some where the nowiki does make a difference
Line 838:
| [[Haskell]] ([[Glasgow Haskell Compiler|GHC]])
| {{n/a}}
| <code><nowiki>Complex{{Not a typo|.}}Complex Float</nowiki></code>
| <code><nowiki>Complex{{Not a typo|.}}Complex Double</nowiki></code>
|-
| [[Eiffel (programming language)|Eiffel]]
Line 1,657:
** <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><nowiki>name {{=}} initial_value</nowiki></code>
| <code>Imports ''synonym'' = ''type''</code>
|-
Line 1,752:
* {{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 <code><nowiki>:{{=}}</nowiki></code> operators, respectively.
* {{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.