Content deleted Content added
m →Other types: cell templates, {{code}} |
m →Other types: syntaxhighlight |
||
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.
|