Comparison of programming languages (basic instructions)

Last updated

This article compares a large number of programming languages by tabulating their data types, their expression, statement, and declaration syntax, and some common operating-system interfaces.

Contents

Conventions of this article

Generally, var, var, or var is how variable names or other non-literal values to be interpreted by the reader are represented. The rest is literal code. Guillemets (« and ») enclose optional sections. Tab ↹ indicates a necessary (whitespace) indentation.

The tables are not sorted lexicographically ascending by programming language name by default, and that some languages have entries in some tables but not others.

Type identifiers

Integers

8 bit (byte)16 bit (short integer)32 bit64 bit (long integer)Word sizeArbitrarily precise (bignum)
SignedUnsignedSignedUnsignedSignedUnsignedSignedUnsignedSignedUnsigned
Ada [1] range -2**7 .. 2**7 - 1 [j] range 0 .. 2**8 - 1 [j] or mod 2**8 [k] range -2**15 .. 2**15 - 1 [j] range 0 .. 2**16 - 1 [j] or mod 2**16 [k] range -2**31 .. 2**31 - 1 [j] range 0 .. 2**32 - 1 [j] or mod 2**32 [k] range -2**63 .. 2**63 - 1 [j] mod 2**64 [k] Integer [j] range 0 .. 2**Integer'Size - 1 [j] or mod Integer'Size [k]
ALGOL 68 (variable-width)short short int [c] short int [c] int [c] long int [c] int [c] long long int [a] [g]
bytes and bits
C (C99 fixed-width)int8_tuint8_tint16_tuint16_tint32_tuint32_tint64_tuint64_tintptr_t [c] size_t [c]
C++ (C++11 fixed-width)
C (C99 variable-width)signed charunsigned charshort [c] unsigned short [c] long [c] unsigned long [c] long long [c] unsigned long long [c] int [c] unsigned int [c]
C++ (C++11 variable-width)
Objective-C (Cocoa)signed char or int8_tunsigned char or uint8_tshort or int16_tunsigned short or uint16_tint or int32_tunsigned int or uint32_tlong long or int64_tunsigned long long or uint64_tNSInteger or longNSUInteger or unsigned long
C# sbytebyteshortushortintuintlongulongIntPtrUIntPtrSystem.Numerics.BigInteger
(.NET 4.0)
Java bytechar [b] java.math.BigInteger
Go int8uint8 or byteint16uint16int32uint32int64uint64intuintbig.Int
Rust i8u8i16u16i32u32i64u64isizeusize
Swift Int8UInt8Int16UInt16Int32UInt32Int64UInt64IntUInt
D byteubyteshortushortintuintlongulongBigInt
Common Lisp [2] (signed-byte 8)(unsigned-byte 8)(signed-byte 16)(unsigned-byte 16)(signed-byte 32)(unsigned-byte 32)(signed-byte 64)(unsigned-byte 64)bignum
Scheme
ISLISP [3] bignum
Pascal (FPC)shortintbytesmallintwordlongintlongwordint64qwordintegercardinal
Visual Basic ByteIntegerLong
Visual Basic .NET SByteShortUShortIntegerUIntegerLongULongSystem.Numerics.BigInteger
(.NET 4.0)
FreeBasic Byte or Integer<8>UByte or UInteger<8>Short or Integer<16>UShort or UInteger<16>Long or Integer<32>ULong or UInteger<32>LongInt or Integer<64>ULongInt or UInteger<64>IntegerUInteger
Python 2.xintlong
Python 3.xint
S-Lang
Fortran INTEGER(KIND = n) [f] INTEGER(KIND = n) [f] INTEGER(KIND = n) [f] INTEGER(KIND = n) [f]
PHP int [m] int [m] [e]
Perl 5 [d] [d] [d] [d] [d] Math::BigInt
Raku int8uint8int16uint16int32uint32int64uint64Int
Ruby FixnumBignum
Erlang [n] integer()integer() [o]
Scala ByteShortChar [l] IntLongscala.math.BigInt
Seed7 integerbigInteger
Smalltalk SmallInteger [i] LargeInteger [i]
Windows PowerShell
OCaml int32int64int or nativeintopen Big_int;; or big_int
F# sbytebyteint16uint16int32 or intuint32uint64nativeintunativeintbigint
Standard ML Word8.wordInt32.intWord32.wordInt64.intWord64.wordintwordLargeInt.int or
IntInf.int
Haskell (GHC)«import Int» or Int8«import Word» or Word8«import Int» or Int16«import Word» or Word16«import Int» or Int32«import Word» or Word32«import Int» or Int64«import Word» or Word64Int«import Word» or WordInteger
Eiffel INTEGER_8NATURAL_8INTEGER_16NATURAL_16INTEGER_32NATURAL_32INTEGER_64NATURAL_64INTEGERNATURAL
COBOL [h] BINARY-CHAR «SIGNED»BINARY-CHAR UNSIGNEDBINARY-SHORT «SIGNED»BINARY-SHORT UNSIGNEDBINARY-LONG «SIGNED»BINARY-LONG UNSIGNEDBINARY-DOUBLE «SIGNED»BINARY-DOUBLE UNSIGNED
Mathematica Integer
Wolfram Language Integer

Floating point

Single precision Double precision Other precisionProcessor dependent
Ada [1] FloatLong_Float
ALGOL 68 real [a] long real [a] short real, long long real, etc. [d]
C float [b] doublelong double [f]
C++ (STL)
Objective-C (Cocoa)CGFloat
C# float
Java
Go float32float64
Rust f32f64
Swift Float or Float32Double or Float64Float80 [g] CGFloat
D floatdoublereal
Common Lisp single-floatdouble-floatfloat, short-float, long-float
Scheme
ISLISP
Pascal (FPC)singledoublereal
Visual Basic SingleDouble
Visual Basic .NET
Xojo
Python float
JavaScript Number [7]
S-Lang
Fortran REAL(KIND = n) [c]
PHP float
Perl
Raku num32num64Num
Ruby Float
Scala FloatDouble
Seed7 float
Smalltalk FloatDouble
Windows PowerShell
OCaml float
F# float32
Standard ML real
Haskell (GHC)FloatDouble
Eiffel REAL_32REAL_64
COBOL FLOAT-BINARY-7 [e] FLOAT-BINARY-34 [e] FLOAT-SHORT, FLOAT-LONG, FLOAT-EXTENDED
Mathematica Real

Complex numbers

IntegerSingle precisionDouble precisionHalf and Quadruple precision etc.
Ada [1] Complex [b] Complex [b] Complex [b]
ALGOL 68 compllong compl etc.short compl etc. and long long compl etc.
C (C99) [9] float complexdouble complex
C++ (STL)std::complex<float>std::complex<double>
C# System.Numerics.Complex
(.NET 4.0)
Java
Go complex64complex128
D cfloatcdouble
Objective-C
Common Lisp (complex integer)(complex single-float)(complex double-float)complex
Scheme
Pascal
Visual Basic
Visual Basic .NET System.Numerics.Complex
(.NET 4.0)
Perl Math::Complex
Raku complex64complex128Complex
Python complex
JavaScript
S-Lang
Fortran COMPLEX(KIND = n) [a]
Ruby ComplexComplex
Scala
Seed7 complex
Smalltalk ComplexComplexComplex
Windows PowerShell
OCaml Complex.t
F# System.Numerics.Complex
(.NET 4.0)
Standard ML
Haskell (GHC)Complex.Complex FloatComplex.Complex Double
Eiffel
COBOL
Mathematica ComplexComplex

Other variable types

Text Boolean Enumeration Object/Universal
Character String [a]
Ada [1] CharacterString, Bounded_String, Unbounded_StringBoolean(item1, item2, ...)tagged null record
ALGOL 68 charstring, bytesbool, bits— - User defined
C (C99)char, wchar_tbool [b] enum «name» { item1, item2, ... }; void *
C++ (STL) «std::»string
Objective-C unicharNSString *BOOLid
C# charstringboolenum name { item1« = value», item2« = value», ... }object
Java Stringbooleanenum name { item1, item2, ... }Object
Go byte, runestringboolconst (
   item1 = iota
   item2
   ...
)
interface{}
Rust charStringboolenum name { item1« = value», item2« = value», ... }std::any::Any
Swift CharacterStringBoolenum name { case item1, item2, ... }Any
D charstringboolenum name { item1, item2, ... }std.variant.Variant
Common Lisp characterstringboolean(member item1item2...)t
Scheme
ISLISP
Pascal (ISO)charboolean( item1, item2, ... )
Object Pascal (Delphi)stringvariant
Visual Basic StringBooleanEnum name
   item1 «= value»
   item2 «= value»
   ...

End Enum
[[Variant type|Variant]]
Visual Basic .NET CharObject
Xojo Object or Variant
Python [d] strboolfrom enum import Enum
class Name(Enum):
   item1 = value
   item2 = value
   ...
object
JavaScript [d] StringBooleanObject
S-Lang
Fortran CHARACTER(LEN = *)CHARACTER(LEN = :), allocatableLOGICAL(KIND = n) [f] CLASS(*)
PHP [d] stringbool(type declaration omitted)
Perl [d] UNIVERSAL
Raku CharStrBoolenum name<item1 item2 ...>
enum name <<:item1(value) :item2(value) ..>>
Mu
Ruby [d] StringObject [c] Object
Scala CharStringBooleanobject name extends Enumeration {
   val item1, item2, ... = Value
}
Any
Seed7 charstringbooleanconst type: name is new enum
   item1,
   item2,
   ...
end enum;
Windows PowerShell
OCaml charstringbool [e]
F# type name = item1 = value|item2 = value|...obj
Standard ML [e]
Haskell (GHC)CharStringBool [e]
Eiffel CHARACTERSTRINGBOOLEANANY
COBOL PIC XPIC X(string length) or PIC X«X...»PIC 1«(number of digits or PIC 1«1...»OBJECT REFERENCE
Mathematica [d] String

Derived types

Array

fixed size arraydynamic size array
one-dimensional array multidimensional array one-dimensional array multidimensional array
Ada [1] array (<first> ..<last>) of<type>
or
array (<discrete_type>) of<type>
array (<first1> ..<last1>,<first2> ..<last2>, ...) of<type>
or
array (<discrete_type1>,<discrete_type2>, ...) of<type>
array (<discrete_type> range <>) of<type>array (<discrete_type1> range <>, <discrete_type2> range <>, ...) of<type>
ALGOL 68 [first:last]«modename»
or simply:
[size]«modename»
[first1:last1, first2:last2]«modename»
or
[first1:last1][first2:last2]«modename»
etc.
flex[first:last]«modename»
or simply:
flex[size]«modename»
flex[first1:last1, first2:last2]«modename»
or
flex[first1:last1]flex[first2:last2]«modename» etc.
C (C99)type name[size] [a] type name[size1][size2] [a] type *name
or within a block:
int n = ...; type name[n]
C++ (STL) «std::»array<type, size>(C++11) «std::»vector<type>
C# type[]type[,,...]System.Collections.ArrayList
or
System.Collections.Generic.List<type>
Java type[] [b] type[][]... [b] ArrayList or ArrayList<type>
D type[size]type[size1][size2]type[]
Go [size]type[size1][size2]...type[]type[][]type
Rust [type; size][[type; size1]; size2]Vec<type>Vec<Vec<type>>
Swift [type] or Array<type>[[type]] or Array<Array<type>>
Objective-C NSArrayNSMutableArray
JavaScript Array [d]
Common Lisp (simple-array type (dimension))(simple-array type (dimension1 dimension2))(array type (dimension))(array type (dimension1 dimension2))
Scheme
ISLISP
Pascal array[first..last] of type [c] array[first1..last1] of array[first2..last2] ... of type [c]
or
array[first1..last1, first2..last2, ...] of type [c]
Object Pascal (Delphi)array of typearray of array ... of type
Visual Basic Dim x(last) As typeDim x(last1, last2,...) As type
Visual Basic .NET type()type(,,...)System.Collections.ArrayList
or
System.Collections.Generic.List(Of type)
Python list
S-Lang x = type[size];x = type[size1, size2, ...];
Fortran type :: name(size)type :: name(size1, size2,...)type, ALLOCATABLE :: name(:)type, ALLOCATABLE :: name(:,:,...)
PHP array
Perl
Raku Array[type] or Array of type
Ruby x = Array.new(size1){ Array.new(size2) }Array
Scala Array[type]Array[...[Array[type]]...]ArrayBuffer[type]
Seed7 array type
or
array [idxType] type
array array type
or
array [idxType] array [idxType] type
array type
or
array [idxType] type
array array type
or
array [idxType] array [idxType] type
Smalltalk ArrayOrderedCollection
Windows PowerShell type[]type[,,...]
OCaml type arraytype array ... array
F# type []
or
type array
type [,,...]System.Collections.ArrayList
or
System.Collections.Generic.List<type>
Standard ML type vector or type array
Haskell (GHC)x = Array.array (0, size-1) list_of_association_pairsx = Array.array ((0, 0,...), (size1-1, size2-1,...)) list_of_association_pairs
COBOL level-number type OCCURS size «TIMES».one-dimensional array definition...level-number type OCCURS min-size TO max-size «TIMES» DEPENDING «ON» size. [e]

Other types

Simple composite types Algebraic data types Unions
Records Tuple expression
Ada [1] type name is «abstract» «tagged» «limited» [record
  field1 : type;
  field2 : type;
  ...
end record | null record]
Any combination of records, unions, and enumerations (as well as references to those, enabling recursive types).type name (variation : discrete_type) is record
  case variation is
  when choice_list1 =>
   fieldname1 : type;
   ...
  when choice_list2 =>
   fieldname2 : type;
   ...
  ...
  end case;
end record
ALGOL 68 struct (modename «fieldname», ...);Required types and operators can be user-defined union (modename, ...);
C (C99)struct «name» {type name;...};union {type name;...};
Objective-C
C++ struct «name» {type name;...}; [b] «std::»tuple<type1..typen>
C# struct name {type name;...}(val1, val2, ... )
Java [a]
JavaScript
D struct name {type name;...}std.variant.Algebraic!(type,...)union {type name;...}
Go struct {
  «name» type
  ...
}
Rust struct name {name: type, ...}(val1, val2, ... )enum name { Foo(types), ...}union name {name: type, ...}
Swift struct name {
  
var name «: type»
  ...
}
(«name1:» val1, «name2:» val2, «name3:» val3, ... )enum name { case Foo«(types)» case Bar «(types... }
Common Lisp (defstruct name slot-name (slot-name initial-value) (slot-name initial-value :type type) ...)(cons val1 val2) [c]
Scheme
ISLISP
Pascal record
  name: type;
  ...
end
record
  case type of
  value: (types);
  ...
end
Visual Basic
Visual Basic .NET Structure name
  Dim name As type
  ...
End Structure
(val1, val2, ... )
Python [a] «(»val1, val2, val3, ... «)»
S-Lang struct {name [=value], ...}
Fortran TYPE name
  type
 :: name
  ...
END TYPE
PHP [a]
Perl [d]
Raku [a]
Ruby OpenStruct.new({:name=>value})
Scala case class namevar» name: type, ...)(val1, val2, val3, ... )abstract class name
  case class Fooparameters») extends name
  case class Barparameters») extends name
  ...

or
abstract class name
  case object Foo extends name
  case object Bar extends name
  ...

or a combination of case classes and case objects
Windows PowerShell
OCaml type name = {«mutable» name : type;...}«(»val1, val2, val3, ... «)»type name = Foo «of type» |Bar «of type» |...
F#
Standard ML type name = {name : type,...}(val1, val2, val3, ... )datatype name = Foo «of type» |Bar «of type» |...
Haskell data Name = Constr {name :: type,...}data Name = Foo «types» |Bar «types» |...
COBOL level-number name type clauses.
  level-number+n name type clauses.
  ...
name REDEFINES variable type.

Variable and constant declarations

variableconstanttype synonym
Ada [1] identifier : type« := initial_value» [e] identifier : constant type := final_valuesubtype identifier is type
ALGOL 68 modename name« := initial_value»;modename name = value; mode synonym = modename;
C (C99)type name« = initial_value»;enum{ name = value }; typedef type synonym;
Objective-C
C++ const type name = value;
C# type name1« = initial_value», name2« = initial_value», ...;
or
var name = initial_value;
const type name = value, name = value, ...;
or
readonly type name = value, name = value, ... ;
using synonym = type;
D type name« = initial_value»;
or
auto name = value;
const type name = value;
or
immutable type name = value;
alias type synonym;
Java type name« = initial_value»;final type name = value;
JavaScript var name« = initial_value»; or
let name« = initial_value»; (since ECMAScript 2015)
const name = value; (since ECMAScript 2015)
Go var name type« = initial_value»
or
name := initial_value
const name «type» = valuetype synonym type
Rust [f] let mut name«: type»« = initial_value»;
static mut NAME: type = value;
let name«: type»« = initial_value»;
const NAME: type = value;

static NAME: type = value;
type synonym = typename;
Swift var name «: type»« = initial_value»let name «: type» = valuetypealias synonym = type
Common Lisp (defparameter name initial-value)
or
(defvar name initial-value)
(defconstant name value)(deftype synonym () 'type)
Scheme (define name initial_value)
ISLISP (defglobal name initial_value)
or
(defdynamic name initial_value)
(defconstant name value)
Pascal [a] name: type« = initial_value»name = valuesynonym = type
Visual Basic Dim name «As type»See notes to left.

Constants use the same syntax, and:

  • use Const instead of Dim
  • have a restriction to only certain primitive types
    Const name1 «As type» = value, name2 «As type» = value, ...
Visual Basic .NET [10] The variable declaration syntax of VB.NET is unusually difficult to precisely describe.

Given that there exist the identifier suffixes ("modifiers"):

  • type_character, available as an alternative to an As clause for some primitive data types;
  • nullable_specifier; and
  • array_specifier;

and that

  • a modified_identifier is of the form identifier«type_character»«nullable_specifier»«array_specifier»;
  • a modified_identifier_list is a comma-separated list of two or more occurrences of modified_identifier; and
  • a declarator_list is a comma-separated list of declarators, which can be of the form
    • identifier As object_creation_expression (object initializer declarator),
    • modified_identifier «As non_array_type«array_rank_specifier»»« = initial_value»(single declarator), or
    • modified_identifier_list «As «non_array_type««array_rank_specifier»»(multiple declarator);

valid declaration statements are of the form    Dim declarator_list, where, for the purpose of semantic analysis, to convert the declarator_list to a list of only single declarators:

  • The As clauses of each multiple declarator is distributed over its modified_identifier_list
  • The As New type... of each object initializer declarator is replaced with As type = New type...

and for which, for each identifier,

  • a type_character and As clause do not both appear;
  • if an As clause is present,
    • an array_rank_specifier does not appear both as a modification of the identifier and on the type of the As clause;
  • an unmodified_type can be determined, by the rule that,
    • if a type_character or As clause is present,
      • unmodified_type is that specified by such construct,
    • and that otherwise,
      • either Option Infer must be on and the identifier must have an initializer, in which case unmodified_type is that of the initializer, or
      • Option Strict must be off, in which case unmodified_type is Object;
  • its final_type is its unmodified_type prepended before its modifiers;
  • its final_type is a valid type; and
  • if an initial_value is present,
    • either Option Strict is on and initial_value has a widening conversion to final_type, or
    • Option Strict is off and initial_value has a narrowing conversion to final_type.

If Option Explicit is off, variables do not require explicit declaration; they are declared implicitly when used: name = initial_value

Imports synonym = type
Xojo Dim name «As type»« = initial_value»
Python name«: type» = initial_valuesynonym = type [b]
CoffeeScript name = initial_value
S-Lang name = initial_value;typedef struct {...} typename
Fortran type nametype, PARAMETER :: name = value
PHP $name = initial_value;define("name", value);
const name = value (5.3+)
Perl «my» $name« = initial_value»; [c] use constant name => value;
Raku «my «type»» $name« = initial_value»; [c] «my «type»» constant name = value;::synonym ::= type
Ruby name = initial_valueName = valuesynonym = type [b]
Scala var name«: type» = initial_valueval name«: type» = valuetype synonym = type
Windows PowerShell «[type]» $name = initial_value
Bash shell name=initial_value
OCaml let name« : type ref» = ref value [d] let name «: type» = valuetype synonym = type
F# let mutable name «: type» = value
Standard ML val name «: type ref» = ref value [d] val name «: type» = value
Haskell «name::typename = valuetype Synonym = type
Forth VARIABLE name (in some systems use value VARIABLE name instead)value CONSTANT name
COBOL level-number name type clauses.«0»1 name CONSTANT «AS» value.level-number name type clauses «IS» TYPEDEF.
Mathematica name=initial_value

Control flow

Conditional statements

ifelse if select case conditional expression
Ada [1] if condition then
  statements
«else
  statements»
end if
if condition1 then
  statements
elsif condition2 then
  statements
...
«else
  statements»
end if
case expression is
  when value_list1 => statements
  when value_list2 => statements
  ...
  «when others => statements»
end case
(if condition1 then
  expression1
«elsif condition2 then
  expression2»
...
else
  expressionn
)

or
(case expression is
  when value_list1 => expression1
  when value_list2 => expression2
  ...
  «when others => expressionn»
)
Seed7 if condition then
  statements
«else
  statements»
end if
if condition1 then
  statements
elsif condition2 then
  statements
...
«else
  statements»
end if
case expression of
  when set1 : statements
  ...
  «otherwise: statements»
end case
Modula-2 if condition then
  statements
«else
  statements»
end
if condition1 then
  statements
elsif condition2 then
  statements
...
«else
  statements»
end
case expression of
  caseLabelList : statements|
  ...
  «else statements»
end
ALGOL 68 if condition then statements «else statements» fiif condition then statements elif condition then statements ficase switch in statements, statements«,... out statements» esac( condition | valueIfTrue | valueIfFalse )
ALGOL 68
(brief form)
( condition | statements «| statements» )( condition | statements |: condition | statements )( variable | statements,... «| statements» )
APL :If condition
  instructions
«:Else
  instructions»
:EndIf
:If condition
  instructions
:ElseIf condition
  instructions
...
«:Else
  instructions»
:EndIf
:Select expression
  :Case case1
  instructions
  ...
  «:Else
  instructions»
:EndSelect
{condition:valueIfTruevalueIfFalse}
C (C99)if (condition) instructions
«else instructions»

instructions can be a single statement or a block in the form of: { statements }
if (condition) instructions
else if (condition) instructions
...
«else instructions»

or
if (condition) instructions
else { if (condition) instructions }
switch (variable) {
  case case1: instructions «; break;»
  ...
  «default: instructions»
}
condition ? valueIfTrue : valueIfFalse
Objective-C
C++ (STL)
D
Java
JavaScript
PHP
C# if (condition) instructions
«else instructions»

instructions can be a single statement or a block in the form of: { statements }

if (condition) instructions
else if (condition) instructions
...
«else instructions»
switch (variable)
{
  case case1:
  instructions
  «break_or_jump_statement»
  ...
  «default:
  instructions
  break_or_jump_statement»
}

All non-empty cases must end with a break or goto case statement (that is, they are not allowed to fall-through to the next case). The default case is not required to come last.

condition ? valueIfTrue : valueIfFalse
Windows PowerShell if (condition) instruction
«else instructions»
if (condition) { instructions }
elseif (condition) { instructions }
...
«else { instructions
switch (variable) { case1{instructions «break;» } ... «default { instructions }»}
Go if condition {instructions}
«else {instructions
if condition {instructions}
else if condition {instructions}
...
«else {instructions

or
switch {
  case condition: instructions
  ...
  «default: instructions»
}
switch variable {
  case case1: instructions
  ...
  «default: instructions»
}
Swift if condition {instructions}
«else {instructions
if condition {instructions}
else if condition {instructions}
...
«else {instructions
switch variable {
  case case1: instructions
  ...
  «default: instructions»
}
Perl if (condition) {instructions}
«else {instructions

or
unless (notcondition) {instructions}
«else {instructions
if (condition) {instructions}
elsif (condition) {instructions}
...
«else {instructions

or
unless (notcondition) {instructions}
elsif (condition) {instructions}
...
«else {instructions
use feature "switch";
...
given (variable) {
  when (case1) { instructions }
  ...
  «default { instructions
}
condition ? valueIfTrue : valueIfFalse
Raku if condition {instructions}
«else {instructions

or
unless notcondition {instructions}
if condition {instructions}
elsif condition {instructions}
...
«else {instructions}
given variable {
  when case1 { instructions }
  ...
  «default { instructions
}
condition ?? valueIfTrue !! valueIfFalse
Ruby if condition
  instructions
«else
  instructions»
if condition
  instructions
elsif condition
  instructions
...
«else
  instructions»
end
case variable
  when case1
  instructions
  ...
  «else
  instructions»
end
condition ? valueIfTrue : valueIfFalse
Scala if (condition) {instructions}
«else {instructions
if (condition) {instructions}
else if (condition) {instructions}
...
«else {instructions
expression match {
  case pattern1 => expression
  case pattern2 => expression
  ...
  «case _ => expression»
}
[b]
if (condition) valueIfTrue else valueIfFalse
Smalltalk condition ifTrue:
  trueBlock
«ifFalse:
  falseBlock»
end
condition ifTrue: trueBlock ifFalse: falseBlock
Common Lisp (when condition
  instructions)

or
(unless condition
  instructions)

or
(if condition
  (progn instructions)
  «(progn instructions)»)
(cond (condition1 instructions)
  (condition2 instructions)
  ...
  «(t instructions)»)
(case expression
  (case1 instructions)
  (case2 instructions)
  ...
  «(otherwise instructions)»)
(if test then else)
or
(cond (test1 value1) (test2 value2) ...))
Scheme (when condition instructions)
or
(if condition (begin instructions) «(begin instructions)»)
(cond (condition1 instructions) (condition2 instructions) ... «(else instructions)»)(case (variable) ((case1) instructions) ((case2) instructions) ... «(else instructions)»)(if condition valueIfTrue valueIfFalse)
ISLISP (if condition
  (progn instructions)
  «(progn instructions)»)
(cond (condition1 instructions)
  (condition2 instructions)
  ...
  «(t instructions)»)
(case expression
  (case1 instructions)
  (case2 instructions)
  ...
  «(t instructions)»)
(if condition valueIfTrue valueIfFalse)
Pascal if condition then begin
  instructions
end
«else begin
  instructions
end»'
[c]
if condition then begin
  instructions
end
else if condition then begin
  instructions
end
...
«else begin
  instructions
end»
[c]
case variable of
  case1: instructions
  ...
  «else: instructions»
end
[c]
Visual Basic If condition Then
  instructions
«Else
  instructions»
End If

Single-line, when instructions are instruction1 : instruction2 : ...:
If condition Then instructions «Else instructions»
If condition Then
  instructions
ElseIf condition Then
  instructions
...
«Else
  instructions»
End If

Single-line:
See note about C-like languages; the Else clause of a single-line If statement can contain another single-line If statement.
Select« Case» variable
  Case case_pattern1
  instructions
  ...
  «Case Else
  instructions»
End Select
IIf(condition, valueIfTrue, valueIfFalse)
Visual Basic .NET If(condition, valueIfTrue, valueIfFalse)
Xojo
Python [a] if condition :
Tab ↹instructions
«else:
Tab ↹instructions»
if condition :
Tab ↹instructions
elif condition :
Tab ↹instructions
...
«else:
Tab ↹instructions»
Python 3.10+:
match variable:
Tab ↹case case1:
Tab ↹Tab ↹instructions
Tab ↹case case2:
Tab ↹Tab ↹instructions
Python 2.5+:
valueIfTrue if condition else valueIfFalse
S-Lang if (condition) { instructions } «else { instructionsif (condition) { instructions } else if (condition) { instructions } ... «else { instructionsswitch (variable) { case case1: instructions } { case case2: instructions } ...
Fortran IF (condition) THEN
  instructions
ELSE
  instructions
ENDIF
IF (condition) THEN
  instructions
ELSEIF (condition) THEN
  instructions
...
ELSE
  instructions
ENDIF
SELECT CASE(variable)
  CASE (case1)
  instructions
  ...
  CASE DEFAULT
  instructions
END SELECT
Forth condition IF instructions « ELSE instructions» THENcondition IF instructions ELSE condition IF instructions THEN THENvalue CASE
  case OF instructions ENDOF
  case OF instructions ENDOF
  default instructions
ENDCASE
condition IF valueIfTrue ELSE valueIfFalse THEN
OCaml if condition then begin instructions end «else begin instructions end»if condition then begin instructions end else if condition then begin instructions end ... «else begin instructions end»match value with
  pattern1 -> expression
  |pattern2 -> expression
  ...
  «| _ -> expression»
[b]
if condition then valueIfTrue else valueIfFalse
F# Lightweight syntax mode:

Either on a single line or with indentation as shown below: if condition then
Tab ↹instructions
«else
Tab ↹instructions»

Verbose syntax mode:
Same as Standard ML.

Lightweight syntax mode:
Either on a single line or with indentation as shown below:
if condition then
Tab ↹instructions
elif condition then
Tab ↹instructions
...
«else
Tab ↹instructions»

Verbose syntax mode:
Same as Standard ML.
Standard ML if condition then «(»instructions «
else «(» instructions «
if condition then «(»instructions «
else if condition then «(» instructions «
...
else «(» instructions «
case value of
  pattern1 => expression
  |pattern2 => expression
  ...
  «| _ => expression»
[b]
Haskell (GHC)if condition then expression else expression
or
when condition (do instructions)
or
unless notcondition (do instructions)
result|condition = expression
  |condition = expression
  | otherwise = expression
case value of {
  pattern1 -> expression;
  pattern2 -> expression;
  ...
  «_ -> expression»
}
[b]
Bash shell if condition-command; then
  expression
«else
  expression»
fi
if condition-command; then
  expression
elif condition-command; then
  expression
«else
  expression»
fi
case "$variable" in
  "$condition1" )
  command...
  "$condition2" )
  command...

esac
CoffeeScript if condition then expression «else expression»
or
if condition
  expression

«else
  expression»

or
expression if condition
or
unless condition
  expression
«else
  expression»

or
expression unless condition
if condition then expression else if condition then expression «else expression»
or
if condition
  expression
else if condition
  expression

«else
  expression»

or
unless condition
  expression
else unless condition
  expression

«else
  expression»
switch expression
  when condition then expression
  else expression

or
switch expression
  when condition
  expression
  «else
  expression»
All conditions are expressions.
COBOL IF condition «THEN»
  expression
«ELSE
  expression».
[d]
EVALUATE expression «ALSO expression...»
  WHEN case-or-condition «ALSO case-or-condition...»
  expression
  ...

  «WHEN OTHER
  expression»
END-EVALUATE
Rust if condition {
  expression
 else {
  expression
if condition {
  expression
} else if condition {
  expression
 else {
  expression
}»
match variable {
  pattern1 => expression,
  pattern2 => expression,
  pattern3 => expression,
  «_ => expression»
}
[b] [e]
All conditions are expressions
ifelse if select case conditional expression

Loop statements

while loop do while loop (count-controlled) for loop foreach
Ada [1] while condition loop
  statements
end loop
loop
  statements
  exit when not condition
end loop
for index in «reverse» [first .. last | discrete_type] loop
  statements
end loop
for item of «reverse» iterator loop
  statements
end loop

or
(for [all | some] [in | of] [first .. last | discrete_type | iterator] => predicate) [b]
ALGOL 68 «for index» «from first» «by increment» «to last» «while condition» do statements odfor key «to upb list» do «typename val=list[key];» statements od
«while condition»
  do statements od
«while statements; condition»
  do statements od
«for index» «from first» «by increment» «to last» do statements od
APL :While condition
  statements
:EndWhile
:Repeat
  statements
:Until condition
:For var«s» :In list
  statements
:EndFor
:For var«s» :InEach list
  statements
:EndFor
C (C99)instructions can be a single statement or a block in the form of: { statements }
while (condition) instructions
do instructions while (condition);for («type» i = first; i <= last; i++) instructions
Objective-C for (type item in set) instructions
C++ (STL)«std::»for_each(start, end, function)
Since C++11:
for (type item : set) instructions
C# foreach (type item in set) instructions
Java for (type item : set) instructions
JavaScript for (var i = first; i <= last; i++) instructionsSince EcmaScript 2015: [11]

for (var item of set) instructions

PHP foreach (range(first, last) as $i) instructions
or
for ($i = first; $i <= last; $i++) instructions
foreach (set as item) instructions
or
foreach (set as key => item) instructions
Windows PowerShell for ($i = first; $i -le last; $i++) instructionsforeach (item in set) instructions
D foreach (i; first ... last) instructionsforeach («type» item; set) instructions
Go for condition { instructions }for i := first; i <= last; i++ { instructions }for key, item := range set { instructions }
Swift while condition { instructions }2.x:
repeat { instructions } while condition
1.x:
do { instructions } while condition
for i = first ... last { instructions }
or
for i = first ..< last+1 { instructions }
or
for var i = first; i <= last; i++ { instructions }
for item in set { instructions }
Perl while (condition) { instructions }
or
until (notcondition) { instructions }
do { instructions } while (condition)
or
do { instructions } until (notcondition)
for«each» «$i» (first .. last) { instructions }
or
for ($i = first; $i <= last; $i++) { instructions }
for«each» «$item» (set) { instructions }
Raku while condition { instructions }
or
until notcondition { instructions }
repeat { instructions } while condition
or
repeat { instructions } until notcondition
for first..last -> $i { instructions }
or
loop ($i = first; $i <=last; $i++) { instructions }
for set« -> $item» { instructions }
Ruby while condition
  instructions
end

or
until notcondition
  instructions
end
begin
  instructions
end while condition

or
begin
  instructions
end until notcondition
for i in first..last
  instructions
end

or
for i in first...last+1
  instructions
end

or
first.upto(last) { |i|instructions }
for item in set
  instructions
end

or
set.each { |item|instructions }
Bash shell while condition ;do
  instructions
done

or
until notcondition ;do
  instructions
done
for ((i = first; i <= last; ++i)) ; do
  instructions
done
for item in set ;do
  instructions
done
Scala while (condition) { instructions }do { instructions } while (condition)for (i <- first to last «by 1») { instructions }
or
first to last «by 1» foreach (i => { instructions })
for (item <- set) { instructions }
or
set foreach (item => { instructions })
Smalltalk conditionBlock whileTrue:
  loopBlock
loopBlock doWhile:
  conditionBlock
first to: last do:
  loopBlock
collection do:
  loopBlock
Common Lisp (loop
  while condition
  do
  instructions)

or
(do () (notcondition)
  instructions)
(loop
  do
  instructions
  while condition)
(loop
  for i from first to last «by 1»
  do
  instructions)

or
(dotimes (i N)
  instructions)

or
(do ((i first (1+ i))) ((>=i last))

  instructions)
(loop
  for item in list
  do
  instructions)

or
(loop
  for item across vector
  do
  instructions)

or
(dolist (item list)
  instructions)

or
(mapc function list)
or
(map type function sequence)
Scheme (do () (notcondition) instructions)
or
(let loop () (if condition (begin instructions (loop))))
(let loop () (instructions (if condition (loop))))(do ((i first (+ i 1))) ((>= i last)) instructions)
or
(let loop ((i first)) (if (< i last) (begin instructions (loop (+ i 1)))))
(for-each (lambda (item) instructions) list)
ISLISP (while condition instructions)(tagbody loop instructions (if condition (go loop))(for ((i first (+ i 1))) ((>= i last)) instructions)(mapc (lambda (item) instructions) list)
Pascal while condition do begin
  instructions
end
repeat
  instructions
until notcondition;
for i := first «step 1» to last do begin
  instructions
end;
[a]
for item in set do instructions
Visual Basic Do While condition
  instructions
Loop

or
Do Until notcondition
  instructions
Loop

or
While condition
  instructions
Wend
(Visual Basic .NET uses End While instead)
Do
  instructions
Loop While condition

or
Do
  instructions
Loop Until notcondition
i must be declared beforehand.

For i = first To last «Step
  instructions

Next i

For Each item In set
  instructions
Next item
Visual Basic .NET For i« As type» = first To last« Step
  instructions

Next« 
[a]
For Each item« As type» In set
  instructions
Next« item»
Xojo While condition
  instructions
Wend
Do Until notcondition
  instructions
Loop

or
Do
  instructions
Loop Until notcondition
Python while condition :
Tab ↹instructions
«else:
Tab ↹instructions»
Python 3.x:
for i in range(first, last+1):
Tab ↹instructions
«else:
Tab ↹instructions»

Python 2.x:
for i in xrange(first, last+1):
Tab ↹instructions
«else:
Tab ↹instructions»
for item in set:
Tab ↹instructions
«else:
Tab ↹instructions»
S-Lang while (condition) { instructions } «then optional-block»do { instructions } while (condition) «then optional-block»for (i = first; i <= last; i++) { instructions } «then optional-block»foreach item(set) «using (what)» { instructions } «then optional-block»
Fortran DO WHILE (condition)
  instructions
ENDDO
DO
  instructions
  IF (condition) EXIT
ENDDO
DO I = first,last
  instructions
ENDDO
Forth BEGIN «instructions» condition WHILE instructions REPEATBEGIN instructions condition UNTILlimit start DO instructions LOOP
OCaml while condition do instructions donefor i = first to last do instructions doneArray.iter (fun item -> instructions) array
or
List.iter (fun item -> instructions) list
F# while condition do
Tab ↹instructions
for i = first to last do
Tab ↹instructions
foritem in set do
Tab ↹instructions

or
Seq.iter (fun item -> instructions) set
Standard ML while condition do ( instructions )Array.app (fn item => instructions) array
or
app (fn item => instructions) list
Haskell (GHC)Control.Monad.forM_ [first..last] (\i -> do instructions)Control.Monad.forM_list (\item -> do instructions)
Eiffel from
  setup
until
  condition
loop
  instructions
end
CoffeeScript while condition
  expression

or
expression while condition
or
while condition then expression
or
until condition
  expression

or
expression until condition
or
until expression then condition
for i in [first..last]
  expression

or
for i in [first..last] then expression
or
expression for i in [first..last]
for item in set
  expression

or
for item in set then expression
or
expression for item in set
COBOL PERFORM procedure-1 «THROUGH procedure-2» ««WITH» TEST BEFORE» UNTIL condition [c]
or
PERFORM ««WITH» TEST BEFORE» UNTIL condition
  expression
END-PERFORM
PERFORM procedure-1 «THROUGH procedure-2» «WITH» TEST AFTER UNTIL condition [c]
or
PERFORM «WITH» TEST AFTER UNTIL condition
  expression
END-PERFORM
PERFORM procedure-1 «THROUGH procedure-2» VARYING i FROM first BY increment UNTIL i > last [d]
or
PERFORM VARYING i FROM first BY increment UNTIL i > last
  expression
END-PERFORM
[d]
Rust while condition {
  expression
}
loop {
  expression
  if condition {
   break;
  }
}
for i in first..last+1 {
  expression
}

or
for i in first..=last {
  expression
}
for item in set {
  expression
}
[e]
or
set.into_iter().for_each(|item| expression); [e]

Exceptions

throwhandlerassertion
Ada [1] raise exception_name «with string_expression»begin
  statements
exception
  when exception_list1=>statements;
  when exception_list2=>statements;
...
  «when others =>statements;»
end
[b]
pragma Assert («Check =>» boolean_expression ««Message =>» string_expression»)
[function | procedure | entry] with
  Pre =>boolean_expression
  Post =>boolean_expression
any_type with Type_Invariant =>boolean_expression
APL «string_expression» ⎕SIGNAL number_expression:Trap number«s»_expression
  statements
«:Case number«s»_expression
  statements»
...
«:Else number«s»_expression
  statements»
:EndTrap
«string_expression» ⎕SIGNAL 98/⍨~condition
C (C99) longjmp(state, exception);switch (setjmp(state)) { case 0: instructions break; case exception: instructions ... }assert(condition);
C++ throw exception;try { instructions } catch «(exception)» { instructions } ...
C# try { instructions } catch «(exception« name»)» { instructions } ... «finally { instructionsSystem.Diagnostics.Debug.Assert(condition);
or
System.Diagnostics.Trace.Assert(condition);
Java try { instructions } catch (exception) { instructions } ... «finally { instructionsassert condition «: description»;
JavaScript try { instructions } catch (exception) { instructions} «finally { instructions?
D try { instructions } catch (exception) { instructions } ... «finally { instructionsassert(condition);
PHP try { instructions } catch (exception) { instructions } ... «finally { instructionsassert(condition);
S-Lang try { instructions } catch «exception» { instructions } ... «finally { instructions?
Windows PowerShell trap «[exception]» { instructions } ... instructions
or
try { instructions } catch «[exception]» { instructions } ... «finally { instructions
[Debug]::Assert(condition)
Objective-C @throw exception;@try { instructions } @catch (exception) { instructions } ... «@finally { instructionsNSAssert(condition, description);
Swift throw exception (2.x)do { try expression ... instructions } catch exception { instructions } ... (2.x)assert(condition«, description»)
Perl die exception;eval { instructions }; if ($@) { instructions }?
Raku try { instructions CATCH { when exception { instructions } ...}}?
Ruby raise exceptionbegin
  instructions
rescue exception
  instructions
...
«else
  instructions»
«ensure
  instructions»
end
Smalltalk exception raiseinstructionBlock on: exception do: handlerBlockassert: conditionBlock
Common Lisp (error "exception")
or
(error
  type
  arguments)

or
(error (make-condition
  type
  arguments))
(handler-case
  (progn instructions)
  (exception instructions)
  ...)

or
(handler-bind
  (condition
  (lambda
  instructions
  «invoke-restart restart args»))
...)
[a]
(assert condition)
or
(assert condition
  «(place)
  «error»»)

or
(check-type var type)
Scheme (R6RS)(raise exception)(guard (con (condition instructions) ...) instructions)?
ISLISP (error "error-string" objects)
or
(signal-condition condition continuable)
(with-handler
  handler form*
)
?
Pascal raise Exception.Create()try Except on E: exception do begin instructions end; end;?
Visual Basic Err.Raise ERRORNUMBERWith New Try: On Error Resume Next
  OneInstruction
.Catch
: On Error GoTo 0: Select Case .Number
  Case SOME_ERRORNUMBER
  instructions
End Select: End With
'*** Try class ***PrivatemstrDescriptionAsStringPrivatemlngNumberAsLongPublicSubCatch()mstrDescription=Err.DescriptionmlngNumber=Err.NumberEndSubPublicPropertyGetNumber()AsLongNumber=mlngNumberEndPropertyPublicPropertyGetDescription()AsStringDescription=mstrDescriptionEndProperty
[12]
Debug.Assert condition
Visual Basic .NET Throw exception
or
Error errorcode
Try
  instructions
Catch« name As exception»« When condition»
  instructions
...
«Finally
  instructions»
End Try
System.Diagnostics.Debug.Assert(condition)
or
System.Diagnostics.Trace.Assert(condition)
Xojo Raise exceptionTry
  instructions
Catch «exception»
  instructions
...
«Finally
  instructions»
End Try
Python raise exceptiontry:
Tab ↹instructions
except «exception»:
Tab ↹instructions
...
«else:
Tab ↹instructions»
«finally:
Tab ↹instructions»
assert condition
Fortran
Forth code THROWxt CATCH ( code or 0 )
OCaml raise exceptiontry expression with pattern -> expression ...assert condition
F# try expression with pattern -> expression ...
or
try expression finally expression
Standard ML raise exception «arg»expression handle pattern => expression ...
Haskell (GHC)throw exception
or
throwError expression
catch tryExpression catchExpression
or
catchError tryExpression catchExpression
assert condition expression
COBOL RAISE «EXCEPTION» exceptionUSE «AFTER» EXCEPTION OBJECT class-name.
or
USE «AFTER» EO class-name.
or
USE «AFTER» EXCEPTION CONDITION exception-name «FILE file-name».
or
USE «AFTER» EC exception-name «FILE file-name».
Rust No [13] assert!(condition)

Other control flow statements

exit block (break)continue label branch (goto)return value from generator
Ada [1] exit «loop_name» «when condition»label:goto label
ALGOL 68 value exit; ...do statements; skip exit; label: statements odlabel: ...go to label; ...
goto label; ...
label; ...
yield(value)

(Callback) [14]

APL :Leave:Continuelabel:label
or
:GoTo label
C (C99)break;continue;label:goto label;
Objective-C
C++ (STL)
D
C# yield return value;
Java break «label»;continue «label»;
JavaScript yield value«;»
PHP break «levels»;continue «levels»;goto label;yield «key =>» value;
Perl last «label»;next «label»;
Raku
Go break «label»continue «label»goto label
Swift break «label»continue «label»
Bash shell break «levels»continue «levels»
Common Lisp (return)
or
(return-from block)
or
(loop-finish)
(tagbody tag
  ...
  tag
...)
(go tag)
Scheme
ISLISP (return-from block)(tagbody tag
  ...
  tag
...)
(go tag)
Pascal (ISO)label: [a] goto label;
Pascal (FPC)break;continue;
Visual Basic Exit blockAlternatively, for methods,
Return
label:GoTo label
Xojo Continue block
Visual Basic .NET Yield value
Python breakcontinueyield value
RPG IV LEAVE;ITER;
S-Lang break;continue;
Fortran EXITCYCLElabel [b] GOTO label
Ruby breaknext
Windows PowerShell break «label»continue
OCaml
F#
Standard ML
Haskell (GHC)
COBOL EXIT PERFORM or EXIT PARAGRAPH or EXIT SECTION or EXIT.EXIT PERFORM CYCLElabel «SECTION».GO TO label

Functions

See reflective programming for calling and declaring functions by strings.

calling a functionbasic/void functionvalue-returning functionrequired main function
Ada [1] foo «(parameters)»procedure foo «(parameters)» is begin statements end foofunction foo «(parameters)» return type is begin statements end foo
ALGOL 68 foo «(parameters)»;proc foo = «(parameters)» void: ( instructions );proc foo = «(parameters)» rettype: ( instructions ...; retvalue );
APL «parameters» foo parametersfoo←{ statements }foo←{ statements }
C (C99)foo(«parameters») void foo(«parameters») { instructions }typefoo(«parameters») { instructions ... return value; }«global declarations»
int main(«int argc, char *argv[]») {
  instructions
}
Objective-C
C++ (STL)
Java public static void main(String[] args) { instructions }
or
public static void main(String... args) { instructions }
D int main(«char[][] args») { instructions}
or
int main(«string[] args») { instructions}
or
void main(«char[][] args») { instructions}
or
void main(«string[] args») { instructions}
C# Same as above; alternatively, if only one statement:

void foo(«parameters») => statement;

Same as above; alternatively, if simple enough to be an expression:

void foo(«parameters») => expression;

static void Main(«string[] args») method_body
May instead return int.
(starting with C# 7.1:) May return Task or Task<int>, and if so, may be async.
JavaScript function foo(«parameters») { instructions }
or
var foo = function («parameters») { instructions }
or
var foo = new Function ("«parameter»", ..., "«last parameter»" "instructions");
function foo(«parameters») { instructions ... return value; }
Go func foo(«parameters») { instructions }func foo(«parameters») type { instructions ... return value }func main() { instructions }
Swift func foo(«parameters») { instructions }func foo(«parameters») -> type { instructions ... return value }
Common Lisp (foo «parameters»)(defun foo («parameters»)
  instructions)

or
(setf (symbol-function 'symbol)
  function)
(defun foo («parameters»)
  ...
  value
)
Scheme (define (foo parameters) instructions)
or
(define foo (lambda (parameters) instructions))
(define (foo parameters) instructions... return_value)
or
(define foo (lambda (parameters) instructions... return_value))
ISLISP (defun foo («parameters»)
  instructions)
(defun foo («parameters»)
  ...
  value
)
Pascal foo«(parametersprocedure foo«(parameters)»; «forward;» [a]
«label
  label declarations»
«const
  constant declarations»
«type
  type declarations»
«var
  variable declarations»
«local function declarations»

begin
  instructions
end;
function foo«(parameters)»: type; «forward;» [a]
«label
  label declarations»
«const
  constant declarations»
«type
  type declarations»
«var
  variable declarations»
«local function declarations»

begin
  instructions;
  foo := value
end;
program name;
«label
  label declarations»
«const
  constant declarations»
«type
  type declarations»
«var
  variable declarations»
«function declarations»

begin
  instructions
end.
Visual Basic Foo(«parameters»)Sub Foo«(parameters
  instructions
End Sub
Function Foo«(parameters)»« As type»
  instructions
  Foo = value
End Function
Sub Main()
  instructions
End Sub
Visual Basic .NET Same as above; alternatively:

Function Foo«(parameters)»« As type»
  instructions
  Return value
End Function

The As clause is not required if Option Strict is off. A type character may be used instead of the As clause.
If control exits the function without a return value having been explicitly specified, the function returns the default value for the return type.

Sub Main(««ByVal »args() As String»)
  instructions
End Sub
or
Function Main(««ByVal »args() As String») As Integer
  instructions
End Function
Xojo
Python foo(«parameters»)def foo(«parameters»):
Tab ↹instructions
def foo(«parameters»):
Tab ↹instructions
Tab ↹return value
S-Lang foo(«parameters» «;qualifiers»)define foo («parameters») { instructions }define foo («parameters») { instructions ... return value; }public define slsh_main () { instructions }
Fortran foo («arguments»)
CALL sub_foo («arguments»)
[c]
SUBROUTINE sub_foo («arguments»)
  instructions
END SUBROUTINE
[c]
type FUNCTION foo («arguments»)
  instructions
  ...
  foo = value
END FUNCTION
[c]
PROGRAM main
  instructions
END PROGRAM
Forth «parameters» FOO: FOO « stack effect comment: ( before -- ) »
  instructions
;
: FOO « stack effect comment: ( before -- after ) »
  instructions
;
PHP foo(«parameters»)function foo(«parameters») { instructions }function foo(«parameters») { instructions ... return value; }
Perl foo(«parameters»)
or
&foo«(parameters
sub foo { «my (parameters) = @_;» instructions }sub foo { «my (parameters) = @_;» instructions... «return» value; }
Raku foo(«parameters»)
or
&foo«(parameters
«multi »sub foo(parameters) { instructions }«our «type» »«multi »sub foo(parameters) { instructions ... «return» value; }
Ruby foo«(parametersdef foo«(parameters
  instructions
end
def foo«(parameters
  instructions
  «return» value
end
Rust foo(«parameters»)fn foo(«parameters») { instructions }fn foo(«parameters») -> type { instructions }fn main() { instructions }
Scala foo«(parametersdef foo«(parameters)»«: Unit =» { instructions }def foo«(parameters)»«: type» = { instructions ... «return» value }def main(args: Array[String]) { instructions }
Windows PowerShell foo «parameters»function foo { instructions };
or
function foo { «param(parametersinstructions }
function foo «(parameters)» { instructions ... return value };
or
function foo { «param(parametersinstructions ... return value }
Bash shell foo «parameters»function foo {
  instructions
}

or
foo () {
  instructions
}
function foo {
  instructions
  return «exit_code»
}

or
foo () {
  instructions
  return «exit_code»
}
  • parameters
    • $n ($1, $2, $3, ...)
    • $@ (all parameters)
    • $# (the number of parameters)
    • $0 (this function name)
OCaml foo parameterslet «rec» foo parameters = instructionslet «rec» foo parameters = instructions... return_value
F# [<EntryPoint>] let main args = instructions
Standard ML fun foo parameters = ( instructions )fun foo parameters = ( instructions... return_value )
Haskell foo parameters = do
Tab ↹instructions
foo parameters = return_value
or
foo parameters = do
Tab ↹instructions
Tab ↹return value
«main :: IO ()»
main = do instructions
Eiffel foo («parameters»)foo («parameters»)
  require
  preconditions
  do
  instructions
  ensure
  postconditions
  end
foo («parameters»): type
  require
  preconditions
  do
  instructions
  Result := value
  ensure
  postconditions
  end
[b]
CoffeeScript foo()foo = ->foo = ->value
foo parametersfoo = () ->foo = ( parameters ) ->value
COBOL CALL "foo" «USING parameters»
  «exception-handling»
«
END-CALL»
[d]
«IDENTIFICATION DIVISION.»
PROGRAM-ID. foo.
«other divisions...»
PROCEDURE DIVISION «USING parameters».
  instructions
.
«IDENTIFICATION DIVISION.»
PROGRAM-ID/FUNCTION-ID. foo.
«other divisions...»
DATA DIVISION.
«other sections...»
LINKAGE SECTION.
«parameter definitions...»
variable-to-return definition
«other sections...»
PROCEDURE DIVISION «USING parameters» RETURNING variable-to-return.
  instructions.
«FUNCTION» foo«(«parameters»)»

Type conversions

Where string is a signed decimal number:

string to integerstring to long integerstring to floating pointinteger to stringfloating point to string
Ada [1] Integer'Value (string_expression)Long_Integer'Value (string_expression)Float'Value (string_expression)Integer'Image (integer_expression)Float'Image (float_expression)
ALGOL 68 with general, and then specific formatsWith prior declarations and association of: string buf := "12345678.9012e34 "; file proxy; associate(proxy, buf);
get(proxy, ivar);get(proxy, livar);get(proxy, rvar);put(proxy, ival);put(proxy, rval);
getf(proxy, ($g$, ivar));
or
getf(proxy, ($dddd$, ivar));
getf(proxy, ($g$, livar));
or
getf(proxy, ($8d$, livar));
getf(proxy, ($g$, rvar));
or
getf(proxy, ($8d.4dE2d$, rvar));
putf(proxy, ($g$, ival));
or
putf(proxy, ($4d$, ival));
putf(proxy, ($g(width, places, exp)$, rval));
or
putf(proxy, ($8d.4dE2d$, rval));
APL string_expressionstring_expressionstring_expressioninteger_expressionfloat_expression
C (C99)integer = atoi(string);long = atol(string);float = atof(string); sprintf(string, "%i", integer); sprintf(string, "%f", float);
Objective-C integer = [string intValue];long = [string longLongValue];float = [string doubleValue];string = [NSString stringWithFormat:@"%i", integer];string = [NSString stringWithFormat:@"%f", float];
C++ (STL)«std::»istringstream(string) >> number;«std::»ostringstream o; o << number; string = o.str();
C++11 integer = «std::»stoi(string);long = «std::»stol(string);float = «std::»stof(string); double = «std::»stod(string);string = «std::»to_string(number);
C# integer = int.Parse(string);long = long.Parse(string);float = float.Parse(string);double = double.Parse(string);string = number.ToString();
D integer = std.conv.to!int(string)long = std.conv.to!long(string)float = std.conv.to!float(string)
double = std.conv.to!double(string)
string = std.conv.to!string(number)
Java integer = Integer.parseInt(string);long = Long.parseLong(string);float = Float.parseFloat(string);
double = Double.parseDouble(string);
string = Integer.toString(integer);
string = String.valueOf(integer);
string = Float.toString(float);
string = Double.toString(double);
JavaScript [a] integer = parseInt(string);float = parseFloat(string);
float = new Number (string);
float = Number (string);
float = +string;
string = number.toString ();
string = String (number);
string = number+"";
string = `${number}`
Go integer, error = strconv.Atoi(string)
integer, error = strconv.ParseInt(string, 10, 0)
long, error = strconv.ParseInt(string, 10, 64)float, error = strconv.ParseFloat(string, 64)string = strconv.Itoa(integer)
string = strconv.FormatInt(integer, 10)
string = fmt.Sprint(integer)
string = strconv.FormatFloat(float)
string = fmt.Sprint(float)
Rust [d] string.parse::<i32>()
i32::from_str(string)
string.parse::<i64>()
i64::from_str(string)
string.parse::<f64>()
f64::from_str(string)
integer.to_string()float.to_string()
Common Lisp (setf integer (parse-integer string))(setf float (read-from-string string))(setf string (princ-to-string number))
Scheme (define number (string->number string))(define string (number->string number))
ISLISP (setf integer (convert string<integer>))(setf float (convert string<float>))(setf string (convert number<string>))
Pascalinteger := StrToInt(string);float := StrToFloat(string);string := IntToStr(integer);string := FloatToStr(float);
Visual Basic integer = CInt(string)long = CLng(string)float = CSng(string)
double = CDbl(string)
string = CStr(number)
Visual Basic .NET
(can use both VB syntax above and .NET methods shown right)
integer = Integer.Parse(string)long = Long.Parse(string)float = Single.Parse(string)
double = Double.Parse(string)
string = number.ToString()
Xojo integer = Val(string)long = Val(string)double = Val(string)
double = CDbl(string)
string = CStr(number)
or
string = Str(number)
Python integer = int(string)long = long(string)float = float(string)string = str(number)
S-Lang integer = atoi(string);long = atol(string);float = atof(string);string = string(number);
Fortran READ(string,format) numberWRITE(string,format) number
PHP integer = intval(string);
or
integer = (int)string;
float = floatval(string);
float = (float)string;
string = "$number";
or
string = strval(number);
or
string = (string)number;
Perl [b] number = 0 + string;string = "number";
Raku number = +string;string = ~number;
Ruby integer = string.to_i
or
integer = Integer(string)
float = string.to_f
float = Float(string)
string = number.to_s
Scala integer = string.toIntlong = string.toLongfloat = string.toFloatdouble = string.toDoublestring = number.toString
Smalltalk integer := Integer readFrom: stringfloat := Float readFrom: stringstring := number asString
Windows PowerShell integer = [int]stringlong = [long]stringfloat = [float]stringstring = [string]number;
or
string = "number";
or
string = (number).ToString()
OCaml let integer = int_of_string stringlet float = float_of_string stringlet string = string_of_int integerlet string = string_of_float float
F# let integer = int stringlet integer = int64 stringlet float = float stringlet string = string number
Standard ML val integer = Int.fromString stringval float = Real.fromString stringval string = Int.toString integerval string = Real.toString float
Haskell (GHC)number = read stringstring = show number
COBOL MOVE «FUNCTION» NUMVAL(string) [c] TO numberMOVE number TO numeric-edited

Standard stream I/O

read fromwrite to
stdin stdout stderr
Ada [1] Get (x)Put (x)Put (Standard_Error, x)
ALGOL 68 readf(($format$, x));
or
getf(stand in, ($format$, x));
printf(($format$, x));
or
putf(stand out, ($format$, x));
putf(stand error, ($format$, x)); [a]
APL x←⎕←x⍞←x
C (C99) scanf(format, &x);
or
fscanf(stdin, format, &x); [b]
printf(format, x);
or
fprintf(stdout, format, x); [c]
fprintf(stderr, format, x); [d]
Objective-C data=[[NSFileHandlefileHandleWithStandardInput]readDataToEndOfFile];[[NSFileHandlefileHandleWithStandardOutput]writeData:data];[[NSFileHandlefileHandleWithStandardError]writeData:data];
C++ «std::»cin >> x;
or
«std::»getline(«std::»cin, str);
«std::»cout << x; «std::»cerr << x;
or
«std::»clog << x;
C# x = Console.Read();
or
x = Console.ReadLine();
Console.Write(«format, »x);
or
Console.WriteLine(«format, »x);
Console.Error.Write(«format, »x);
or
Console.Error.WriteLine(«format, »x);
D x = std.stdio.readln()std.stdio.write(x)
or
std.stdio.writeln(x)
or
std.stdio.writef(format, x)
or
std.stdio.writefln(format, x)
stderr.write(x)
or
stderr.writeln(x)
or
std.stdio.writef(stderr, format, x)
or
std.stdio.writefln(stderr, format, x)
Java x = System.in.read();
or
x = new Scanner(System.in).nextInt();
or
x = new Scanner(System.in).nextLine();
System.out.print(x);
or
System.out.printf(format, x);
or
System.out.println(x);
System.err.print(x);
or
System.err.printf(format, x);
or
System.err.println(x);
Go fmt.Scan(&x)
or
fmt.Scanf(format, &x)
or
x = bufio.NewReader(os.Stdin).ReadString('\n')
fmt.Println(x)
or
fmt.Printf(format, x)
fmt.Fprintln(os.Stderr, x)
or
fmt.Fprintf(os.Stderr, format, x)
Swift x = readLine() (2.x)print(x) (2.x)
println(x) (1.x)
JavaScript
Web Browser implementation
document.write(x)
JavaScript
Active Server Pages
Response.Write(x)
JavaScript
Windows Script Host
x = WScript.StdIn.Read(chars)
or
x = WScript.StdIn.ReadLine()
WScript.Echo(x)
or
WScript.StdOut.Write(x)
or
WScript.StdOut.WriteLine(x)
WScript.StdErr.Write(x)
or
WScript.StdErr.WriteLine(x)
Common Lisp (setf x (read-line))(princ x)
or
(format t format x)
(princ x *error-output*)
or
(format*error-output*format x)
Scheme (R6RS)(define x (read-line))(display x)
or
(format#tformat x)
(display x (current-error-port))
or
(format(current-error-port)format x)
ISLISP (setf x (read-line))(format(standard-output)format x)(format(error-output)format x)
Pascal read(x);
or
readln(x);
write(x);
or
writeln(x);
write(stderr, x);
or
writeln(stderr, x);
Visual Basic Input« promptxPrint x
or
? x
Visual Basic .NET x = Console.Read()
or
x = Console.ReadLine()
Console.Write(«formatx)
or
Console.WriteLine(«format, »x)
Console.Error.Write(«format, »x)
or
Console.Error.WriteLine(«format, »x)
Xojo x = StandardInputStream.Read()
or
x = StandardInputStreame.ReadLine()
StandardOutputStream.Write(x)
or
StandardOutputStream.WriteLine(x)
StdErr.Write(x)
or
StdErr.WriteLine(x)
Python 2.xx = raw_input(«prompt»)print x
or
sys.stdout.write(x)
print>>sys.stderr,x
or
sys.stderr.write(x)
Python 3.xx = input(«prompt»)print(, end=""»)print(, end=""», file=sys.stderr)
S-Lang fgets (&x, stdin) fputs (x, stdout) fputs (x, stderr)
Fortran READ(*,format) variable names
or
READ(INPUT_UNIT,format) variable names [e]
WRITE(*,format) expressions
or
WRITE(OUTPUT_UNIT,format) expressions [e]
WRITE(ERROR_UNIT,format) expressions [e]
Forth buffer length ACCEPT ( # chars read )
KEY ( char )
buffer length TYPE
char EMIT
PHP $x = fgets(STDIN);
or
$x = fscanf(STDIN, format);
print x;
or
echo x;
or
printf(format, x);
fprintf(STDERR, format, x);
Perl $x = <>;
or
$x = <STDIN>;
print x;
or
printf format, x;
print STDERR x;
or
printf STDERR format, x;
Raku $x = $*IN.get;x.print
or
x.say
x.note
or
$*ERR.print(x)
or
$*ERR.say(x)
Ruby x = getsputs x
or
printf(format, x)
$stderr.puts(x)
or
$stderr.printf(format, x)
Windows PowerShell $x = Read-Host«« -Prompt» text»;
or
$x = [Console]::Read();
or
$x = [Console]::ReadLine()
x;
or
Write-Output x;
or
echo x
Write-Error x
OCaml let x = read_int ()
or
let str = read_line ()
or
Scanf.scanf format (fun x ...->...)
print_int x
or
print_endline str
or
Printf.printf format x ...
prerr_int x
or
prerr_endline str
or
Printf.eprintf format x ...
F# let x = System.Console.ReadLine() printf format x ...
or
printfn format x ...
eprintf format x ...
or
eprintfn format x ...
Standard ML val str = TextIO.inputLIne TextIO.stdInprint strTextIO.output(TextIO.stdErr, str)
Haskell (GHC)x <- readLn
or
str<- getLine
print x
or
putStrLn str
hPrint stderr x
or
hPutStrLn stderr str
COBOL ACCEPT xDISPLAY x

Reading command-line arguments

Argument valuesArgument countsProgram name / Script name
Ada [1] Argument (n)Argument_CountCommand_Name
C (C99)argv[n]argcfirst argument
Objective-C
C++
C# args[n]args.LengthAssembly.GetEntryAssembly().Location;
Java args.length
D first argument
JavaScript
Windows Script Host implementation
WScript.Arguments(n)WScript.Arguments.lengthWScript.ScriptName
or
WScript.ScriptFullName
Go os.Args[n]len(os.Args)first argument
Rust [a] std::env::args().nth(n)
std::env::args_os().nth(n)
std::env::args().count()
std::env::args_os().count()
std::env::args().next()
std::env::args_os().next()
Swift Process.arguments[n] or
Process.unsafeArgv[n]
Process.arguments.count or
Process.argc
first argument
Common Lisp ???
Scheme (R6RS)(list-ref (command-line) n)(length (command-line))first argument
ISLISP
Pascal ParamStr(n)ParamCountfirst argument
Visual Basic Command [b] App.Path
Visual Basic .NET CmdArgs(n)CmdArgs.Length[Assembly].GetEntryAssembly().Location
Xojo System.CommandLine(string parsing)Application.ExecutableFile.Name
Python sys.argv[n]len(sys.argv)first argument
S-Lang __argv[n]__argcfirst argument
Fortran DO i = 1,argc
  CALL GET_COMMAND_ARGUMENT (i,argv(i))
ENDDO
argc = COMMAND_ARGUMENT_COUNT ()CALL GET_COMMAND_ARGUMENT (0,progname)
PHP $argv[n]$argcfirst argument
Bash shell $n ($1, $2, $3, ...)
$@ (all arguments)
$#$0
Perl $ARGV[n]scalar(@ARGV)$0
Raku @*ARGS[n]@*ARGS.elems$PROGRAM_NAME
Ruby ARGV[n]ARGV.size$0
Windows PowerShell $args[n]$args.Length$MyInvocation.MyCommand.Name
OCaml Sys.argv.(n)Array.length Sys.argvfirst argument
F# args.[n]args.LengthAssembly.GetEntryAssembly().Location
Standard ML List.nth(CommandLine.arguments(),n)length(CommandLine.arguments())CommandLine.name()
Haskell (GHC)do{args<-System.getArgs;returnlengthargs!!n}do{args<-System.getArgs;returnlengthargs}System.getProgName
COBOL [c]

Execution of commands

Shell commandExecute program Replace current program with new executed program
Ada [1] Not part of the language standard. Commonly done by compiler provided packages or by interfacing to C or POSIX. [16]
C system("command"); execl(path, args);
or
execv(path, arglist);
C++
Objective-C [NSTask launchedTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)arguments];
C# System.Diagnostics.Process.Start(path, argstring);
F#
Go exec.Run(path, argv, envv, dir, exec.DevNull, exec.DevNull, exec.DevNull)os.Exec(path, argv, envv)
Visual Basic Interaction.Shell(command «, WindowStyle» «, isWaitOnReturn»)
Visual Basic .NET Microsoft.VisualBasic.Interaction.Shell(command «, WindowStyle» «, isWaitOnReturn»)System.Diagnostics.Process.Start(path, argstring)
Xojo Shell.Execute(command «, Parameters»)FolderItem.Launch(parameters, activate)
D std.process.system("command");std.process.execv(path, arglist);
Java Runtime.exec(command);
or
new ProcessBuilder(command).start();
JavaScript
Windows Script Host implementation
WScript.CreateObject("WScript.Shell").Run(command «, WindowStyle» «, isWaitOnReturn»);WshShell.Exec(command)
Common Lisp (uiop:run-program command)
Scheme (system command)
ISLISP
Pascal system(command);
OCaml Sys.command command, Unix.open_process_full command env (stdout, stdin, stderr),...Unix.create_process prog args new_stdin new_stdout new_stderr, ...Unix.execv prog args
or
Unix.execve prog args env
Standard ML OS.Process.system commandUnix.execute (path, args)Posix.Process.exec (path, args)
Haskell (GHC)System.system commandSystem.Process.runProcess path args ...Posix.Process.executeFile path True args ...
Perl system(command)
or
$output = `command`
or
$output = qx(command)
exec(path, args)
Ruby system(command)
or
output = `command`
exec(path, args)
PHP system(command)
or
$output = `command`
or
exec(command)
or
passthru(command)
Python os.system(command)
or
subprocess.Popen(command)
subprocess.call(["program", "arg1", "arg2", ...])os.execv(path, args)
S-Lang system(command)
Fortran CALL EXECUTE_COMMAND_LINE (COMMAND «, WAIT» «, EXITSTAT» «, CMDSTAT» «, CMDMSG») [a]
Windows PowerShell [Diagnostics.Process]::Start(command)«Invoke-Item »program arg1 arg2 ...
Bash shell output=`command`
or
output=$(command)
program arg1 arg2 ...

^a Fortran 2008 or newer. [17]

Related Research Articles

In computer science, an integer is a datum of integral data type, a data type that represents some range of mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values. Integers are commonly represented in a computer as a group of binary digits (bits). The size of the grouping varies so the set of integer sizes available varies between different types of computers. Computer hardware nearly always provides a way to represent a processor register or memory address as an integer.

<span class="mw-page-title-main">Data type</span> Attribute of data

In computer science and computer programming, a data type is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these values as machine types. A data type specification in a program constrains the possible values that an expression, such as a variable or a function call, might take. On literal data, it tells the compiler or interpreter how the programmer intends to use the data. Most programming languages support basic data types of integer numbers, floating-point numbers, characters and Booleans.

In object-oriented (OO) and functional programming, an immutable object is an object whose state cannot be modified after it is created. This is in contrast to a mutable object, which can be modified after it is created. In some cases, an object is considered immutable even if some internally used attributes change, but the object's state appears unchanging from an external point of view. For example, an object that uses memoization to cache the results of expensive computations could still be considered an immutable object.

In mathematics and computer science, a higher-order function (HOF) is a function that does at least one of the following:

In computer science, a type signature or type annotation defines the inputs and outputs of a function, subroutine or method. A type signature includes the number, types, and order of the function's arguments. One important use of a type signature is for function overload resolution, where one particular definition of a function to be called is selected among many overloaded forms.

In computer science, primitive data types are a set of basic data types from which all other data types are constructed. Specifically it often refers to the limited set of data representations in use by a particular processor, which all compiled programs must use. Most processors support a similar set of primitive data types, although the specific representations vary. More generally, "primitive data types" may refer to the standard data types built into a programming language. Data types which are not primitive are referred to as derived or composite.

<span class="mw-page-title-main">C syntax</span> Set of rules defining correctly structured programs

The syntax of the C programming language is the set of rules governing writing of software in C. It is designed to allow for programs that are extremely terse, have a close relationship with the resulting object code, and yet provide relatively high-level data abstraction. C was the first widely successful high-level language for portable operating-system development.

<span class="mw-page-title-main">Pointer (computer programming)</span> Object which stores memory addresses in a computer program

In computer science, a pointer is an object in many programming languages that stores a memory address. This can be that of another value located in computer memory, or in some cases, that of memory-mapped computer hardware. A pointer references a location in memory, and obtaining the value stored at that location is known as dereferencing the pointer. As an analogy, a page number in a book's index could be considered a pointer to the corresponding page; dereferencing such a pointer would be done by flipping to the page with the given page number and reading the text found on that page. The actual format and content of a pointer variable is dependent on the underlying computer architecture.

In computer science, a union is a value that may have any of several representations or formats within the same position in memory; that consists of a variable that may hold such a data structure. Some programming languages support special data types, called union types, to describe such values and variables. In other words, a union type definition will specify which of a number of permitted primitive types may be stored in its instances, e.g., "float or long integer". In contrast with a record, which could be defined to contain both a float and an integer; in a union, there is only one value at any given time.

In computer programming, the ternary conditional operator is a ternary operator that is part of the syntax for basic conditional expressions in several programming languages. It is commonly referred to as the conditional operator, ternary if, or inline if. An expression a ? b : c evaluates to b if the value of a is true, and otherwise to c. One can read it aloud as "if a then b otherwise c". The form a ? b : c is by far and large the most common, but alternative syntaxes do exist; for example, Raku uses the syntax a ?? b !! c to avoid confusion with the infix operators ? and !, whereas in Visual Basic .NET, it instead takes the form If(a, b, c).

In mathematics and in computer programming, a variadic function is a function of indefinite arity, i.e., one which accepts a variable number of arguments. Support for variadic functions differs widely among programming languages.

The computer programming languages C and Pascal have similar times of origin, influences, and purposes. Both were used to design their own compilers early in their lifetimes. The original Pascal definition appeared in 1969 and a first compiler in 1970. The first version of C appeared in 1972.

<span class="mw-page-title-main">C data types</span> Data types supported by the C programming language

In the C programming language, data types constitute the semantics and characteristics of storage of data elements. They are expressed in the language syntax in form of declarations for memory locations or variables. Data types also determine the types of operations or methods of processing of data elements.

String functions are used in computer programming languages to manipulate a string or query information about a string.

A class in C++ is a user-defined type or data structure declared with any of the keywords class, struct or union that has data and functions as its members whose access is governed by the three access specifiers private, protected or public. By default access to members of a C++ class declared with the keyword class is private. The private members are not accessible outside the class; they can be accessed only through member functions of the class. The public members form an interface to the class and are accessible outside the class.

sizeof is a unary operator in the programming languages C and C++. It generates the storage size of an expression or a data type, measured in the number of char-sized units. Consequently, the construct sizeof (char) is guaranteed to be 1. The actual number of bits of type char is specified by the preprocessor macro CHAR_BIT, defined in the standard include file limits.h. On most modern computing platforms this is eight bits. The result of sizeof has an unsigned integer type that is usually denoted by size_t.

C++11 is a version of the ISO/IEC 14882 standard for the C++ programming language. C++11 replaced the prior version of the C++ standard, called C++03, and was later replaced by C++14. The name follows the tradition of naming language versions by the publication year of the specification, though it was formerly named C++0x because it was expected to be published before 2010.

This is an overview of Fortran 95 language features. Included are the additional features of TR-15581:Enhanced Data Type Facilities, which have been universally implemented. Old features that have been superseded by new ones are not described – few of those historic features are used in modern programs although most have been retained in the language to maintain backward compatibility. The current standard is Fortran 2023; many of its new features are still being implemented in compilers. The additional features of Fortran 2003, Fortran 2008, Fortran 2018 and Fortran 2023 are described by Metcalf, Reid, Cohen and Bader.

In computer programming, an anonymous function is a function definition that is not bound to an identifier. Anonymous functions are often arguments being passed to higher-order functions or used for constructing the result of a higher-order function that needs to return a function. If the function is only used once, or a limited number of times, an anonymous function may be syntactically lighter than using a named function. Anonymous functions are ubiquitous in functional programming languages and other languages with first-class functions, where they fulfil the same role for the function type as literals do for other data types.

SUPER BASIC, sometimes SBASIC for short, is an advanced dialect of the BASIC programming language offered on Tymshare's SDS 940 systems starting in 1968 and available well into the 1970s.

References

  1. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Ada Reference Manual – Language and Standard Libraries; ISO/IEC 8652:201x (E), "Reference Manual" (PDF). Archived from the original (PDF) on 2011-04-27. Retrieved 2013-07-19.
  2. "Common Lisp HyperSpec (TM)". lispworks.com. Retrieved 30 January 2017.
  3. "www.islisp.info: Specification". islisp.info. Archived from the original on 22 January 2016. Retrieved 30 January 2017.
  4. 1 2 "selected_int_kind in Fortran Wiki". fortranwiki.org. Retrieved 30 January 2017.
  5. "Erlang — Types and Function Specifications". erlang.org. Retrieved 30 January 2017.
  6. "Erlang — Advanced". erlang.org. Retrieved 30 January 2017.
  7. 1 2 8.5 The Number Type
  8. 1 2 "selected_real_kind in Fortran Wiki". fortranwiki.org. Retrieved 30 January 2017.
  9. "The GNU C Library: Complex Numbers". gnu.org. Retrieved 30 January 2017.
  10. "Grammar vb". Visual Basic Language Specification. 2016-06-17. Archived from the original on 2019-08-29. Retrieved 2019-08-29.
  11. "for...of". mozilla.org. Retrieved 30 January 2017.
  12. "Try-Catch for VB". google.com. Archived from the original on 16 April 2016. Retrieved 30 January 2017.
  13. Klabnik, Steve; Nichols, Carol. "Error Handling". The Rust Programming Language.
  14. "Prime decomposition – Rosetta Code". rosettacode.org. Retrieved 30 January 2017.
  15. "iso_fortran_env in Fortran Wiki". fortranwiki.org. Retrieved 30 January 2017.
  16. "Execute a system command – Rosetta Code". rosettacode.org. Retrieved 30 January 2017.
  17. "EXECUTE_COMMAND_LINE – The GNU Fortran Compiler". gnu.org. Retrieved 30 January 2017.