プログラミング言語の比較(基本命令)

この記事では、多数のプログラミング言語のデータ型ステートメント宣言の 構文、および一般的なオペレーティング システム インターフェイスを表にして比較します。

この記事の慣例

一般的に、varvar、またはvarは、変数名やその他の非リテラル値(読者が解釈する値)を表します。残りはリテラルコードです。ギユメ«»)は省略可能なセクションを囲みます。Tab ↹は必要な(空白)インデントを示します。

デフォルトでは、テーブルはプログラミング言語名で辞書式昇順にソートされておらず、一部の言語は一部のテーブルにエントリがあり、他のテーブルにはエントリがありません。

型識別子

8ビット(バイト16ビット(短整数32ビット64ビット(長整数単語サイズ任意の精度(bignum
署名署名なし署名署名なし署名署名なし署名署名なし署名署名なし
エイダ[1]range -2**7 .. 2**7 - 1[j]range 0 .. 2**8 - 1[j]または[k]mod 2**8range -2**15 .. 2**15 - 1[j]range 0 .. 2**16 - 1[j]または[k]mod 2**16range -2**31 .. 2**31 - 1[j]range 0 .. 2**32 - 1[j]または[k]mod 2**32range -2**63 .. 2**63 - 1[j]mod 2**64[k]Integer[j]range 0 .. 2**Integer'Size - 1[j]または[k]mod Integer'Size
ALGOL 68(可変幅)short short int[c]short int[c]int[c]long int[c]int[c]long long int[あ] [ぐ]
bytesそしてbits
C ( C99固定幅)int8_tuint8_tint16_tuint16_tint32_tuint32_tint64_tuint64_tintptr_t[c]size_t[c]
C++ ( C++11固定幅)
C ( C99可変幅)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可変幅)
Objective-C (ココア)signed charまたはint8_tunsigned charまたはuint8_tshortまたはint16_tunsigned shortまたはuint16_tintまたはint32_tunsigned intまたはuint32_tlong longまたはint64_tunsigned long longまたはuint64_tNSIntegerまたはlongNSUIntegerまたはunsigned long
C#sbytebyteshortushortintuintlongulongIntPtrUIntPtrSystem.Numerics.BigInteger
(.NET 4.0)
ジャワbytechar[b]java.math.BigInteger
行くint8uint8またはbyteint16uint16int32uint32int64uint64intuintbig.Int
さびi8u8i16u16i32u32i64u64isizeusize
迅速Int8UInt8Int16UInt16Int32UInt32Int64UInt64IntUInt
DbyteubyteshortushortintuintlongulongBigInt
コモンリスプ[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
スキーム
ISLISP [3]bignum
パスカルFPCshortintbytesmallintwordlongintlongwordint64qwordintegercardinal
ビジュアルベーシックByteIntegerLong
ビジュアルベーシック.NETSByteShortUShortIntegerUIntegerLongULongSystem.Numerics.BigInteger
(.NET 4.0)
フリーベーシックByteまたはInteger<8>UByteまたはUInteger<8>ShortまたはInteger<16>UShortまたはUInteger<16>LongまたはInteger<32>ULongまたはUInteger<32>LongIntまたはInteger<64>ULongIntまたはUInteger<64>IntegerUInteger
Python 2.xintlong
Python 3.xint
S-ラング
フォートランINTEGER(KIND = n)[女性]INTEGER(KIND = n)[女性]INTEGER(KIND = n)[女性]INTEGER(KIND = n)[女性]
PHPint[メートル]int[メートル][e]
パール5[d][d][d][d][d]Math::BigInt
int8uint8int16uint16int32uint32int64uint64Int
ルビーFixnumBignum
アーラン[n]integer()integer()[お]
スカラByteShortChar[l]IntLongscala.math.BigInt
シード7integerbigInteger
雑談SmallInteger[私]LargeInteger[私]
Windows PowerShell
OCamlint32int64intまたはnativeintopen Big_int;;またはbig_int
F#sbytebyteint16uint16int32またはintuint32uint64nativeintunativeintbigint
標準MLWord8.wordInt32.intWord32.wordInt64.intWord64.wordintwordLargeInt.intまたは
IntInf.int
ハスケルGHC«import Int»またはInt8«import Word»またはWord8«import Int»またはInt16«import Word»またはWord16«import Int»またはInt32«import Word»またはWord32«import Int»またはInt64«import Word»またはWord64Int«import Word»またはWordInteger
エッフェル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
マセマティカInteger
ウルフラム言語Integer
  • ^a 標準定数と は、と を接頭辞として付加できるかを決定するために使用できます、 の実際のサイズは定数などとして使用できます。int shortsint lengthsshortlongshort intlong intshort intintlong intshort max intmax intlong max int
  • ^b 文字によく使用されます。
  • ^c ALGOL 68、C、C++ 言語では、整数型shortintlong、 ( C99 C++11 )long longため、これらは実装に依存します。C および C++ ではshortlong、 、long long型はそれぞれ少なくとも 16、32、64 ビット幅である必要がありますが、それ以上にすることもできます。 型はint少なくとも と同じ幅でshort最大でも と同じ幅でlong、 は通常、マシンのプロセッサのワード サイズの幅です (つまり、32 ビット マシンでは 32 ビット幅であることが多く、64 ビット マシンでは 64 ビット幅であることがあります)。C99およびC++11 [引用が必要]では、 stdint.hヘッダーで正確な幅の型も定義されています詳細については、「C 構文#整数型」を参照してください。さらに、型は、配列インデックスやポインタ間の差を処理す​​るのに十分な大きさの符号なし整数と符号付き整数を保持するために、アドレス サイズとの関係で定義されます。[u]intN_tsize_tptrdiff_t
  • ^d Perl 5には明確な型がありません。整数、浮動小数点数、文字列などはすべて「スカラー」とみなされます。
  • PHPに は任意精度のライブラリが2つあります。BCMathライブラリはデータ型として文字列のみを使用します。GMPライブラリは内部的に「リソース」型を使用します。
  • ^f の値は[4]のn組み込み関数によって提供されるSELECTED_INT_KIND
  • ^g ALGOL 68 G のランタイムオプションは--precision "number"の精度をlong long int必要な「数値」桁に設定できます。実際の精度は標準定数long long int widthlong long max intを使用して決定できます。
  • COBOL では、必要な精度を指定でき、指定された精度を表現できる利用可能な型が自動的に選択されます。PIC S9999例えば、「 」は、4桁の10進数精度の符号付き変数を必要とします。バイナリフィールドとして指定した場合、ほとんどのプラットフォームでは16ビットの符号付き型が選択されます。
  • ^i Smalltalkは整数に対して適切な表現を自動的に選択します。通常、2つの表現が存在します。1つはネイティブワードサイズからタグビットを除いた整数( SmallInteger)用、もう1つは任意サイズの整数( LargeInteger)用です。算術演算は多態的な引数をサポートし、結果を最も適切なコンパクトな表現で返します。
  • ^j Adaの範囲型は、実行時(静的式の場合はコンパイル時も同様)に境界違反がないかチェックされます。実行時に境界違反が発生した場合、「制約エラー」例外が発生します。範囲は2の累乗に制限されません。一般的に定義済みの整数サブタイプは、正数()と自然数()です。(8ビット)、(16ビット)、(64ビット)も一般的に定義されていますが、Ada標準では必須ではありません。整合性チェックよりもパフォーマンスが重要な場合は、実行時チェックを無効にできます。range 1 .. Integer'Lastrange 0 .. Integer'LastShort_Short_IntegerShort_IntegerLong_Integer
  • ^k Adaのモジュロ型は、すべての演算においてモジュロ演算を実装します。つまり、範囲違反は発生しません。モジュロは2の累乗に限定されません。
  • ^l Java の char のような文字によく使用されます。
  • PHP の^m は、そのシステム上の C の typeintと同じ幅です。 [c]long
  • ^n Erlangは動的型付けです。型識別子は通常、レコードフィールドの型や関数の引数と戻り値の型を指定するために使用されます。 [5]
  • ^o 1単語を超える場合。 [6]
単精度倍精度その他の精度プロセッサ依存
エイダ[1]FloatLong_Float
アルゴル68real[あ]long real[あ]short real、、long long realなど[d]
Cfloat[b]doublelong double[女性]
C++ (STL)
Objective-C (ココア)CGFloat
C#float
ジャワ
行くfloat32float64
さびf32f64f16, f128
迅速FloatまたはFloat32DoubleまたはFloat64Float80[グラム]CGFloat
Dfloatdoublereal
コモンリスプsingle-floatdouble-floatfloat, short-float, long-float
スキーム
ISLISP
パスカルFPCsingledoublereal
ビジュアルベーシックSingleDouble
ビジュアルベーシック.NET
ゾジョ
パイソンfloat
JavaScriptNumber[7]
S-ラング
フォートランREAL(KIND = n)[c]
PHPfloat
パール
num32num64Num
ルビーFloat
スカラFloatDouble
シード7float
雑談FloatDouble
Windows PowerShell
OCamlfloat
F#float32
標準MLreal
ハスケルGHCFloatDouble
エッフェルREAL_32REAL_64
コボルFLOAT-BINARY-7[e]FLOAT-BINARY-34[e]FLOAT-SHORT、、FLOAT-LONGFLOAT-EXTENDED
マセマティカReal
  • ^a 標準定数real shortsおよび は、およびに付加できるおよび のreal lengths決定するために使用できますの実際のサイズは定数など定数、 、は、各タイプのマシンイプシロンに対して使用できますshortlongshort reallong realshort realreallong realshort max realmax reallong max realshort small realsmall reallong small real
  • ^b 単精度の宣言は無視されることが多い
  • ^c の値は[8]のn組み込み関数によって提供されるSELECTED_REAL_KIND
  • ^d ALGOL 68 G のランタイムオプションはs の精度を必要な「number」桁に--precision "number"設定できます。実際の精度は標準定数を使用して決定できます。long long reallong long real widthlong long max real
  • ^e これらのIEEE浮動小数点型は、次の COBOL 標準で導入される予定です。
  • ^fdouble多くの実装 と同じサイズです
  • ^g Swift は、 C 言語と同等の 80 ビット拡張精度浮動小数点型をサポートしています。long double
整数単精度倍精度半精度、4倍精度など
エイダ[1]Complex[b]Complex[b]Complex[b]
アルゴル68compllong complshort complなどlong long complなど。
CC99[9]float complexdouble complex
C++ (STL)std::complex<float>std::complex<double>
C#System.Numerics.Complex
(.NET 4.0)
ジャワ
行くcomplex64complex128
Dcfloatcdouble
オブジェクティブC
コモンリスプ(複素整数)(複素数単精度浮動小数点数)(複素数倍精度浮動小数点数)複雑な
スキーム
パスカル
ビジュアルベーシック
ビジュアルベーシック.NETSystem.Numerics.Complex
(.NET 4.0)
パールMath::Complex
complex64complex128Complex
パイソンcomplex
JavaScript
S-ラング
フォートランCOMPLEX(KIND = n)[あ]
ルビーComplexComplex
スカラ
シード7complex
雑談ComplexComplexComplex
Windows PowerShell
OCamlComplex.t
F#System.Numerics.Complex
(.NET 4.0)
標準ML
ハスケルGHCComplex.Complex FloatComplex.Complex Double
エッフェル
コボル
マセマティカComplexComplex
  • ^a の値は[8]のn組み込み関数によって提供されるSELECTED_REAL_KIND
  • ^b 任意の基本浮動小数点型でインスタンス化できる汎用型。

その他の変数タイプ

文章ブール値列挙オブジェクト/ユニバーサル
キャラクター文字列[a]
エイダ[1]CharacterString、、Bounded_StringUnbounded_StringBoolean(item1, item2, ...)tagged null record
アルゴル68charstringbytesboolbitsN/A - ユーザー定義該当なし
C ( C99 )charwchar_t該当なしbool[b]enum «name» { item1, item2, ... };void *
C++ (STL)«std::»string
オブジェクティブCunicharNSString *BOOLid
C#charstringboolenum name { item1« = value», item2« = value», ... }物体
ジャワStringbooleanenum name { item1, item2, ... }Object
行くbyterunestringboolconst (
   item1 = iota
   item2
   ...
)
interface{}
さびcharStringboolenum name { item1« = value», item2« = value», ... }std::any::Any
迅速CharacterStringBoolenum name { case item1, item2, ... }Any
Dcharstringboolenum name { item1, item2, ... }std.variant.Variant
コモンリスプcharacterstringboolean(member item1 item2 ...)t
スキーム
ISLISP
パスカル(ISO)char該当なしboolean( item1, item2, ... )該当なし
オブジェクトパスカルデルファイstringvariant
ビジュアルベーシック該当なしStringBooleanEnum name
   item1 «= value»
   item2 «= value»
   ...

End Enum
Variant
ビジュアルベーシック.NETCharObject
ゾジョ該当なしObjectまたはVariant
パイソン該当なし[d]strbool
from enum import Enumclass Name(Enum): 項目1 = 項目2 = ...
object
JavaScript該当なし[d]StringBooleanObject
S-ラング
フォートランCHARACTER(LEN = *)CHARACTER(LEN = :), allocatableLOGICAL(KIND = n)[女性]CLASS(*)
PHP該当なし[d]stringbool(型宣言は省略)
パール該当なし[d]UNIVERSAL
CharStrBoolenum name<item1 item2 ...>
enum name «:item1(value) :item2(value) ..»
Mu
ルビー該当なし[d]StringObject[c]Object
スカラCharStringBooleanobject name extends Enumeration {
   val item1, item2, ... = Value
}
Any
シード7charstringbooleanconst type: name is new enum
   item1,
   item2,
   ...
end enum;
Windows PowerShell
OCamlcharstringbool該当なし[e]該当なし
F#type name = item1 = value |item2 = value | ...obj
標準ML該当なし[e]該当なし
ハスケルGHCCharStringBool該当なし[e]該当なし
エッフェルCHARACTERSTRINGBOOLEAN該当なしANY
コボルPIC XPIC X(string length)またはPIC X«X...»PIC 1«(number of digitsまたはPIC 1«1...»該当なしOBJECT REFERENCE
マセマティカ該当なし[d]String該当なし
  • ^a 具体的には、任意の長さの文字列が自動的に管理されます。
  • ^b この言語ではブール値を整数として表します。false はゼロの値として表され、true はゼロ以外の値として表されます。
  • ^c すべての値は真または偽のいずれかに評価されます。 内のすべての値TrueClassは真に評価され、 内のすべての値FalseClassは偽に評価されます。
  • ^dこの言語には独立した文字型はありません。文字は長さ1の文字列として表現されます。
  • ^e この言語の列挙型は、null引数コンストラクタのみを持つ代数型である。
  • ^f の値は[4]のn組み込み関数によって提供されるSELECTED_INT_KIND

派生型

固定サイズの配列動的サイズ配列
1次元配列多次元配列1次元配列多次元配列
エイダ[1]array (<first> .. <last>) of <type>
または
array (<discrete_type>) of <type>
array (<first1> .. <last1>, <first2> .. <last2>, ...) of <type>
または
array (<discrete_type1>, <discrete_type2>, ...) of <type>
array (<discrete_type> range <>) of <type>array (<discrete_type1> range <>, <discrete_type2> range <>, ...) of <type>
アルゴル68[first:last]«modename»
または単に:
[size]«modename»
[first1:last1, first2:last2]«modename»
など
[first1:last1][first2:last2]«modename»
flex[first:last]«modename»
または単に:
flex[size]«modename»
flex[first1:last1, first2:last2]«modename»
または
flex[first1:last1]flex[first2:last2]«modename» etc.
C ( C99 )type name[size][あ]type name[size1][size2][あ]type *name
またはブロック内では:
int n = ...; type name[n]
C++ (STL)«std::»array<type, size>(C++11)«std::»vector<type>
C#type[]type[,,...]System.Collections.ArrayList
または
System.Collections.Generic.List<type>
ジャワtype[][b]type[][]...[b]ArrayList or ArrayList<type>
Dtype[size]type[size1][size2]type[]
行く[size]type[size1][size2]...type[]type[][]type
さび[type; size][[type; size1]; size2]Vec<type>Vec<Vec<type>>
迅速[type]またはArray<type>[[type]]またはArray<Array<type>>
オブジェクティブCNSArrayNSMutableArray
JavaScriptArray[d]
コモンリスプ(simple-array type (dimension))(simple-array type (dimension1 dimension2))(array type (dimension))(array type (dimension1 dimension2))
スキーム
ISLISP
パスカルarray[first..last] of type[c]array[first1..last1] of array[first2..last2] ... of type[c]
または[c]
array[first1..last1, first2..last2, ...] of type
オブジェクトパスカルデルファイarray of typearray of array ... of type
ビジュアルベーシックDim x(last) As typeDim x(last1, last2,...) As type
ビジュアルベーシック.NETtype()type(,,...)System.Collections.ArrayList
または
System.Collections.Generic.List(Of type)
パイソンlist
S-ラングx = type[size];x = type[size1, size2, ...];
フォートランtype :: name(size)type :: name(size1, size2,...)type, ALLOCATABLE :: name(:)type, ALLOCATABLE :: name(:,:,...)
PHParray
パール
Array[type] or Array of type
ルビーx = Array.new(size1){ Array.new(size2) }Array
スカラArray[type]Array[...[Array[type]]...]ArrayBuffer[type]
シード7array type
または
array [idxType] type
array array type
または
array [idxType] array [idxType] type
array type
または
array [idxType] type
array array type
または
array [idxType] array [idxType] type
雑談ArrayOrderedCollection
Windows PowerShelltype[]type[,,...]
OCamltype arraytype array ... array
F#type []
または
type array
type [,,...]System.Collections.ArrayList
または
System.Collections.Generic.List<type>
標準MLtype vector or type array
ハスケルGHCx = Array.array (0, size-1) list_of_association_pairsx = Array.array ((0, 0,...), (size1-1, size2-1,...)) list_of_association_pairs
コボルlevel-number type OCCURS size «TIMES».1 次元配列の定義...level-number type OCCURS min-size TO max-size «TIMES» DEPENDING «ON» size.[e]
  • ^a C言語のほとんどの式(sizeofand&演算子を除く)では、配列型の値は自動的に最初の引数へのポインタに変換されます。構文とポインタ演算の詳細については、 C言語の構文#配列を参照してください。
  • ^b C のようなtype x[]形式は Java でも動作しますが、type[] x配列宣言の推奨形式です。
  • ^c サブ範囲は配列の境界を定義するために使用されます。
  • ^d JavaScript の配列は特別な種類のオブジェクトです。
  • ^e COBOL の 句は真のDEPENDING ON可変長配列を作成せず、常に配列の最大サイズを割り当てます。

その他のタイプ

単純な複合型代数データ型労働組合
記録タプル
エイダ[1]type name is «abstract» «tagged» «limited» [record
  field1 : type;
  field2 : type;
  ...
end record | null record]
該当なしレコード、ユニオン、列挙の任意の組み合わせ (およびそれらへの参照により再帰型が有効になります)。type name (variation : discrete_type) is record
  case variation is
     when choice_list1 =>
      fieldname1 : type;
      ...
     when choice_list2 =>
      fieldname2 : type;
      ...
     ...
  end case;
end record
アルゴル68struct (modename «fieldname», ...);必要な型と演算子はユーザー定義可能union (modename, ...);
C ( C99 )struct «name» {type name;...};該当なし該当なしunion {type name;...};
オブジェクティブC
C++struct «name» {type name;...};[b]«std::»tuple<type1..typen>
C#struct name {type name;...}(val1, val2, ... )該当なし
ジャワ該当なし[a]
JavaScript該当なし
Dstruct name {type name;...}std.variant.Algebraic!(type,...)union {type name;...}
行くstruct {
  «name» type
  ...
}
さびstruct name {name: type, ...}(val1, val2, ... )enum name { Foo(types), ...}union name {name: type, ...}
迅速struct name {
  
var name «: type»
  ...
}
(«name1:» val1, «name2:» val2, «name3:» val3, ... )enum name { case Foo«(types)» case Bar «(types... }
コモンリスプ(defstruct name slot-name (slot-name initial-value) (slot-name initial-value :type type) ...)(cons val1 val2)[c]
スキーム該当なし
ISLISP
パスカルrecord
  name: type;
  ...
end
該当なし該当なしrecord
  case type of
  value: (types);
  ...
end
ビジュアルベーシック
ビジュアルベーシック.NETStructure name
  Dim name As type
  ...
End Structure
(val1, val2, ... )
パイソン該当なし[a]«(»val1, val2, val3, ... «)»該当なし
S-ラングstruct {name [=value], ...}
フォートランTYPE name
  type
 :: name
  ...
END TYPE
PHP該当なし[a]
パール該当なし[d]該当なし
該当なし[a]
ルビーOpenStruct.new({:name => value})
スカラcase class namevar» name: type, ...)(val1, val2, val3, ... )abstract class name
  case class Fooparameters») extends name
  case class Barparameters») extends name
  ...

またはケースクラスとケースオブジェクトの組み合わせ
abstract class name
  case object Foo extends name
  case object Bar extends name
  ...

Windows PowerShell
OCamltype name = {«mutable» name : type;...}«(»val1, val2, val3, ... «)»type name = Foo «of type» | Bar «of type» | ...該当なし
F#
標準MLtype name = {name : type,...}(val1, val2, val3, ... )datatype name = Foo «of type» | Bar «of type» | ...
ハスケルdata Name = Constr {name :: type,...}data Name = Foo «types» | Bar «types» | ...
コボルlevel-number name type clauses.
  level-number+n name type clauses.
  ...
該当なし該当なしname REDEFINES variable type.
  • ^a クラスのみがサポートされます。
  • structC++ の^bは実際にはクラスですが、デフォルトで public な可視性を持ち、 PODオブジェクトでもあります。C++11 ではこれがさらに拡張され、クラスはより多くのケースで POD オブジェクトと同様に動作するようになりました。
  • ^c ペアのみ
  • ^d Perl にはレコードがありませんが、Perl の型システムでは配列内に異なるデータ型を格納できるため、変数インデックスを持たない「ハッシュ」(連想配列) は実質的にレコードと同じになります。
  • ^e この言語の列挙型は、null引数コンストラクタのみを持つ代数型である。

変数と定数の宣言

変数絶え間ない型同義語
エイダ[1]identifier : type« := initial_value»[e]identifier : constant type := final_valuesubtype identifier is type
アルゴル68modename name« := initial_value»;modename name = value;mode synonym = modename;
C ( C99 )type name« = initial_value»;enum{ name = value };typedef type synonym;
オブジェクティブC
C++const type name = value;
C#type name1« = initial_value», name2« = initial_value», ...;
または
var name = initial_value;
const type name = value, name = value, ...;
または
readonly type name = value, name = value, ... ;
using synonym = type;
Dtype name« = initial_value»;
または
auto name = value;
const type name = value;
または
immutable type name = value;
alias type synonym;
ジャワtype name« = initial_value»;final type name = value;
JavaScriptvar name« = initial_value»;または( ECMAScript 2015以降
let name« = initial_value»;
const name = value;ECMAScript 2015以降)
行くvar name type« = initial_value»
または
name := initial_value
const name «type» = valuetype synonym type
ラケット(define name expression)
[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;
迅速var name «: type»« = initial_value»let name «: type» = valuetypealias synonym = type
コモンリスプ(defparameter name initial-value)
または
(defvar name initial-value)
(defconstant name value)(deftype synonym () 'type)
スキーム(define name initial_value)
ISLISP(defglobal name initial_value)
または
(defdynamic name initial_value)
(defconstant name value)
パスカル[a]name: type« = initial_value»name = valuesynonym = type
ビジュアルベーシックDim name «As type»左の注記を参照してください。

定数は同じ構文を使用します。

  • Const代わりに使用するDim
  • 特定のプリミティブ型のみに制限がある
    Const name1 «As type» = value, name2 «As type» = value, ...
ビジュアルベーシック.NET [10]VB.NET の変数宣言構文は、正確に記述するのが非常に困難です。

識別子の接尾辞(「修飾子」)が存在するとします。

  • type_characterAs一部のプリミティブ データ型の句の代替として使用できます。
  • nullable_specifier; そして
  • array_specifier;

そして

  • amodified_identifierは次の形式ですidentifier«type_character»«nullable_specifier»«array_specifier»
  • aは、;と;modified_identifier_listの2つ以上の出現をコンマで区切ったリストです。modified_identifier
  • aはdeclarator_listカンマで区切られた宣言子のリストであり、次のような形式をとることができる。
    • identifier As object_creation_expression(オブジェクト初期化子宣言子)
    • modified_identifier «As non_array_type«array_rank_specifier»»« = initial_value» (単一の宣言子)または
    • modified_identifier_list «As «non_array_type««array_rank_specifier»» (複数の宣言者)

有効な宣言文は の形式です      。ここで、意味解析を目的として を単一の宣言子のみのリストに変換するには、次のようにします。Dim declarator_listdeclarator_list

  • As多重宣言子の節は、そのmodified_identifier_list
  • オブジェクト初期化宣言子のは次のように置き換えられます。As New type...As type = New type...

そして、各 に対してidentifier

  • type_characterAs節の両方が出現しない。
  • 節が存在する場合As
    • an はarray_rank_specifier識別子の修飾語としても節の型としても現れませんAs
  • unmodified_type、次の規則によって決定することができる。
    • type_characterorAs節が存在する場合、
      • unmodified_typeそのような構成によって規定されるものである、
    • そうでなければ、
      • どちらかがOption Inferオンで、identifier初期化子を持っている必要があります。この場合、unmodified_type初期化子の初期化子、または
      • Option Strictオフにする必要があります。その場合unmodified_typeObject;
  • itsfinal_typeは、unmodified_typeその修飾子の前に付加されます。
  • final_type有効なタイプであり、
  • が存在する場合initial_value
    • のいずれかOption Strictがオンであり、initial_valueへの拡大変換を持つfinal_typeか、
    • Option Strictはオフになっており、initial_valueへの縮小変換が行われますfinal_type

がオフの場合Option Explicit、変数は明示的な宣言を必要とせず、使用時に暗黙的に宣言されます。name = initial_value

Imports synonym = type
ゾジョDim name «As type»« = initial_value»
パイソンname«: type» = initial_valuesynonym = type[b]
コーヒースクリプトname = initial_value
S-ラングname = initial_value;typedef struct {...} typename
フォートランtype :: nametype, PARAMETER :: name = value
PHP$name = initial_value;define("name", value);
const name = value (5.3+)
パール«my» $name« = initial_value»;[c]use constant name => value;
«my «type»» $name« = initial_value»;[c]«my «type»» constant name = value;::synonym ::= type
ルビーname = initial_valueName = valuesynonym = type[b]
スカラvar name«: type» = initial_valueval name«: type» = valuetype synonym = type
Windows PowerShell«[type]» $name = initial_value
Bashシェルname=initial_value
OCamllet name« : type ref» = ref value[d]let name «: type» = valuetype synonym = type
F#let mutable name «: type» = value
標準MLval name «: type ref» = ref value[d]val name «: type» = value
ハスケル«name::typename = valuetype Synonym = type
フォースVARIABLE name(一部のシステムでは代わりに使用value VARIABLE namevalue CONSTANT name
コボルlevel-number name type clauses.«0»1 name CONSTANT «AS» value.level-number name type clauses «IS» TYPEDEF.
マセマティカname=initial_value
  • ^a Pascalには宣言ブロックがあります。関数を参照してください。
  • ^b型は通常のオブジェクトなので、割り当てるだけで済みます。
  • ^c Perl では、「my」キーワードは変数のスコープをブロック内に限定します。
  • ^d技術的には、これはname を可変変数として 宣言しているわけではありません。MLでは、すべての名前は一度しか束縛できません。むしろ、これはname が!「参照」データ構造、つまり単純な可変セルを指すように宣言しています。このデータ構造は、それぞれとを使用して読み書きできます:=
  • ^e 初期値が指定されていない場合、無効な値が自動的に割り当てられます(有効な値が割り当てられる前に無効な値を使用すると、実行時例外が発生します)。この動作は抑制できますが、予測可能性の観点から抑制することをお勧めします。型に無効な値が見つからない場合(例えば、制約のない整数型の場合)、代わりに有効かつ予測可能な値が選択されます。
  • ^f Rustでは、変数letまたはlet mut変数に初期値が与えられておらず、その後も代入されていない場合、「未使用変数」という警告が表示されます。変数constまたはstatic変数static mutはエラーが発生します。大文字以外の変数の場合は「大文字以外のグローバル変数」というエラーが発生しますconst。変数は定義後、static mut内でのみ代入できますunsafe
もしそうでなければケースを選択条件式
エイダ[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
)

または
(case expression is
  when value_list1 => expression1
  when value_list2 => expression2
  ...
  «when others => expressionn»
)
シード7if 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
モジュラ2if 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
アルゴル68if 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
(簡易版)
( 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単一のステートメントまたは次の形式のブロックになります。{ statements }
if (condition) instructions
else if (condition) instructions
...
«else instructions»

または
if (condition) instructions
else { if (condition) instructions }
switch (variable) {
  case case1: instructions «; break;»
  ...
  «default: instructions»
}
condition ? valueIfTrue : valueIfFalse
オブジェクティブC
C++ (STL)
D
ジャワ
JavaScript
PHP
C#if (condition) instructions
«else instructions»

instructions単一のステートメントまたは次の形式のブロックになります。{ 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»
}

空でないすべてのcaseはbreakorgoto case文で終わる必要があります(つまり、次のcaseにフォールスルーすることはできません)。caseはdefault必ずしも最後に来る必要はありません。

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

または
switch {
  case condition: instructions
  ...
  «default: instructions»
}
switch variable {
  case case1: instructions
  ...
  «default: instructions»
}
迅速if condition {instructions}
«else {instructions
if condition {instructions}
else if condition {instructions}
...
«else {instructions
switch variable {
  case case1: instructions
  ...
  «default: instructions»
}
パールif (condition) {instructions}
«else {instructions

または
unless (notcondition) {instructions}
«else {instructions
if (condition) {instructions}
elsif (condition) {instructions}
...
«else {instructions

または
unless (notcondition) {instructions}
elsif (condition) {instructions}
...
«else {instructions
use feature "switch";
...
given (variable) {
  when (case1) { instructions }
  ...
  «default { instructions
}
condition ? valueIfTrue : valueIfFalse
ラケット(when testexpression expressions)
または
(unless condition expressions)
(cond
[testexpression expressions]
[testexpression expressions]
...
[else expressions])
(case expression [(case1) expressions]
[(case2) expressions]
...
[else expressions])
(if testexpression expressioniftrue expressioniffalse)
if condition {instructions}
«else {instructions

または
unless notcondition {instructions}
if condition {instructions}
elsif condition {instructions}
...
«else {instructions}
given variable {
  when case1 { instructions }
  ...
  «default { instructions
}
condition ?? valueIfTrue !! valueIfFalse
ルビー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
スカラ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
雑談condition ifTrue:
  trueBlock
«ifFalse:
  falseBlock»
end
condition ifTrue: trueBlock ifFalse: falseBlock
コモンリスプ(when condition
  instructions)

またはまたは
(unless condition
  instructions)


(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)
または
(cond (test1 value1) (test2 value2) ...))
スキーム(when condition instructions)
または
(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)
パスカル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]
ビジュアルベーシックIf condition Then
  instructions
«Else
  instructions»
End If

単一行のinstructions場合:instruction1 : instruction2 : ...
If condition Then instructions «Else instructions»
If condition Then
  instructions
ElseIf condition Then
  instructions
...
«Else
  instructions»
End If

単一行:
C 系言語に関する注記を参照してください。Else単一行Ifステートメントの句には、別の単一行Ifステートメントを含めることができます。
Select« Case» variable
  Case case_pattern1
     instructions
  ...
  «Case Else
     instructions»
End Select
IIf(condition, valueIfTrue, valueIfFalse)
ビジュアルベーシック.NETIf(condition, valueIfTrue, valueIfFalse)
ゾジョ
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-ラングif (condition) { instructions } «else { instructionsif (condition) { instructions } else if (condition) { instructions } ... «else { instructionsswitch (variable) { case case1: instructions } { case case2: instructions } ...
フォートラン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
フォース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
OCamlif 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#軽量構文モード:

1 行で記述するか、次に示すようにインデントを付けて記述します。詳細構文モード:標準 ML と同じです。if condition then
Tab ↹instructions
«else
Tab ↹instructions»


軽量構文モード:
単一行または以下に示すようにインデント付きで記述します。詳細構文モード:標準 ML と同じです。
if condition then
Tab ↹instructions
elif condition then
Tab ↹instructions
...
«else
Tab ↹instructions»


標準MLif 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]
ハスケルGHCif condition then expression else expression
またはまたは
when condition (do instructions)

unless notcondition (do instructions)
result | condition = expression
  | condition = expression
  | otherwise = expression
case value of {
  pattern1 -> expression;
  pattern2 -> expression;
  ...
  «_ -> expression»
}
[b]
Bashシェル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
コーヒースクリプトif condition then expression «else expression»
またはまたはまたはまたはまたは
if condition
  expression

«else
  expression»


expression if condition

unless condition
  expression
«else
  expression»


expression unless condition
if condition then expression else if condition then expression «else expression»
またはまたは
if condition
  expression
else if condition
  expression

«else
  expression»


unless condition
  expression
else unless condition
  expression

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

または
switch expression
  when condition
     expression
  «else
     expression»
すべての条件は式です。
コボル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
さびif condition {
  expression
}« else {
  expression
if condition {
  expression
} else if condition {
  expression
}« else {
  expression
}»
match variable {
  pattern1 => expression,
  pattern2 => expression,
  pattern3 => expression,
  «_ => expression»
}
[なれ]
すべての条件は式である
もしそうでなければケースを選択条件式
  • ^aコロンの後の行に1つの命令を記述できます。複数の命令は、改行で始まるブロック にまとめられます(インデントが必要です)。条件式の構文はこの規則に従いません。
  • ^b これはパターンマッチングであり、select caseに似ていますが、同じではありません。通常は代数的データ型を分解するために使用されます。
  • ^c Pascal系の言語では、セミコロンは文の一部ではありません。文と文を区切るものであり、文の終端記号ではありません。
  • END-IF末尾のピリオドの代わりに^d を使用することもできます。
  • ^e, Rust では、最後のマッチ アームの後、または式がブロックである (空の一致する括弧で終わる可能性がある) マッチ アームの後の、マッチ アームの末尾の コンマ ({}
whileループdo whileループ(カウント制御)forループforeach
エイダ[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

または[b]
(for [all | some] [in | of] [first .. last | discrete_type | iterator] => predicate)
アルゴル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単一のステートメントまたは次の形式のブロックになります。{ statements }
while (condition) instructions
do instructions while (condition);for («type» i = first; i <= last; i++) instructions
オブジェクティブCfor (type item in set) instructions
C++ (STL)«std::»for_each(start, end, function)
C++11以降:
for (type item : set) instructions
C#foreach (type item in set) instructions
ジャワfor (type item : set) instructions
JavaScriptfor (var i = first; i <= last; i++) instructionsEcmaScript 2015以降: [11]

for (var item of set) instructions

PHPforeach (range(first, last) as $i) instructions
または
for ($i = first; $i <= last; $i++) instructions
foreach (set as item) instructions
または
foreach (set as key => item) instructions
Windows PowerShellfor ($i = first; $i -le last; $i++) instructionsforeach (item in set) instructions
Dforeach (i; first ... last) instructionsforeach («type» item; set) instructions
行くfor condition { instructions }for i := first; i <= last; i++ { instructions }for key, item := range set { instructions }
迅速while condition { instructions }2.x: 1.x:
repeat { instructions } while condition

do { instructions } while condition
for i = first ... last { instructions }
またはまたは
for i = first ..< last+1 { instructions }

for var i = first; i <= last; i++ { instructions }
for item in set { instructions }
パールwhile (condition) { instructions }
または
until (notcondition) { instructions }
do { instructions } while (condition)
または
do { instructions } until (notcondition)
for«each» «$i» (first .. last) { instructions }
または
for ($i = first; $i <= last; $i++) { instructions }
for«each» «$item» (set) { instructions }
while condition { instructions }
または
until notcondition { instructions }
repeat { instructions } while condition
または
repeat { instructions } until notcondition
for first..last -> $i { instructions }
または
loop ($i = first; $i <=last; $i++) { instructions }
for set« -> $item» { instructions }
ルビーwhile condition
  instructions
end

または
until notcondition
  instructions
end
begin
  instructions
end while condition

または
begin
  instructions
end until notcondition
for i in first..last
  instructions
end

またはまたは
for i in first...last+1
  instructions
end


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

または
set.each { |item| instructions }
Bashシェルwhile condition ;do
  instructions
done

または
until notcondition ;do
  instructions
done
for ((i = first; i <= last; ++i)) ; do
  instructions
done
for item in set ;do
  instructions
done
スカラwhile (condition) { instructions }do { instructions } while (condition)for (i <- first to last «by 1») { instructions }
または
first to last «by 1» foreach (i => { instructions })
for (item <- set) { instructions }
または
set foreach (item => { instructions })
雑談conditionBlock whileTrue:
  loopBlock
loopBlock doWhile:
  conditionBlock
first to: last do:
  loopBlock
collection do:
  loopBlock
コモンリスプ(loop
  while condition
  do
  instructions)

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

またはまたは
(dotimes (i N)
  instructions)


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

  instructions)
(loop
  for item in list
  do
  instructions)

またはまたはまたはまたはまたは
(loop
  for item across vector
  do
  instructions)


(dolist (item list)
  instructions)


(mapc function list)

(map type function sequence)
スキーム(do () (notcondition) instructions)
または
(let loop () (if condition (begin instructions (loop))))
(let loop () (instructions (if condition (loop))))(do ((i first (+ i 1))) ((>= i last)) instructions)
または
(let loop ((i first1)) (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)
パスカルwhile condition do begin
  instructions
end
repeat
  instructions
until notcondition;
for i := first «step 1» to last do begin
  instructions
end;
[あ]
for item in set do instructions
ビジュアルベーシックDo While condition
  instructions
Loop

またはまたは(Visual Basic .NETでは代わりに を使用します)
Do Until notcondition
  instructions
Loop


While condition
  instructions
Wend
End While
Do
  instructions
Loop While condition

または
Do
  instructions
Loop Until notcondition
i事前に申告する必要があります。

For i = first To last «Step
  instructions

Next i

For Each item In set
  instructions
Next item
ビジュアルベーシック.NETFor i« As type» = first To last« Step
  instructions

Next« i»
[あ]
For Each item« As type» In set
  instructions
Next« item»
ゾジョWhile condition
  instructions
Wend
Do Until notcondition
  instructions
Loop

または
Do
  instructions
Loop Until notcondition
パイソンwhile condition :
Tab ↹instructions
«else:
Tab ↹instructions»
Python 3.x: Python 2.x:
for i in range(first, last+1):
Tab ↹instructions
«else:
Tab ↹instructions»


for i in xrange(first, last+1):
Tab ↹instructions
«else:
Tab ↹instructions»
for item in set:
Tab ↹instructions
«else:
Tab ↹instructions»
S-ラング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»
フォートランDO WHILE (condition)
  instructions
ENDDO
DO
  instructions
  IF (condition) EXIT
ENDDO
DO I = first,last
  instructions
ENDDO
フォースBEGIN «instructions» condition WHILE instructions REPEATBEGIN instructions condition UNTILlimit start DO instructions LOOP
OCamlwhile condition do instructions donefor i = first to last do instructions doneArray.iter (fun item -> instructions) array
または
List.iter (fun item -> instructions) list
F#while condition do
Tab ↹instructions
for i = first to last do
Tab ↹instructions
for item in set do
Tab ↹instructions

または
Seq.iter (fun item -> instructions) set
標準MLwhile condition do ( instructions )Array.app (fn item => instructions) array
または
app (fn item => instructions) list
ハスケルGHCControl.Monad.forM_ [first..last] (\i -> do instructions)Control.Monad.forM_list (\item -> do instructions)
エッフェルfrom
  setup
until
  condition
loop
  instructions
end
コーヒースクリプトwhile condition
  expression

またはまたはまたはまたはまたはまたは
expression while condition

while condition then expression

until condition
  expression


expression until condition

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

またはまたは
for i in [first..last] then expression

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

またはまたは
for item in set then expression

expression for item in set
コボルPERFORM procedure-1 «THROUGH procedure-2» ««WITH» TEST BEFORE» UNTIL condition[c]
または
PERFORM ««WITH» TEST BEFORE» UNTIL condition
  expression
END-PERFORM
PERFORM procedure-1 «THROUGH procedure-2» «WITH» TEST AFTER UNTIL condition[c]
または
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]
または[d]
PERFORM VARYING i FROM first BY increment UNTIL i > last
  expression
END-PERFORM
さびwhile condition {
  expression
}
loop {
  expression
     if condition {
      break;
  }
}
for i in first..last+1 {
  expression
}

または
for i in first..=last {
  expression
}
for item in set {
  expression
}
[e]
または[e]
set.into_iter().for_each(|item| expression);
  • ^a "stepn" はループ間隔を変更するために使用されます。"step" を省略した場合、ループ間隔は1になります。
  • ^b これは、全称量指定子(「すべてに対して」または)と存在量指定子(「存在する」または)を実装します。
  • THRUの代わりに^c がTHROUGH使用されることもあります。
  • の代わりに^d が使用されることもあります。«IS» GREATER «THAN»>
  • ^e セット式の型は特性を実装する必要がありますstd::iter::IntoIterator
投げるハンドラ主張
エイダ[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);
または
System.Diagnostics.Trace.Assert(condition);
ジャワtry { instructions } catch (exception) { instructions } ... «finally { instructionsassert condition «: description»;
JavaScripttry { instructions } catch (exception) { instructions} «finally { instructions?
Dtry { instructions } catch (exception) { instructions } ... «finally { instructionsassert(condition);
PHPtry { instructions } catch (exception) { instructions } ... «finally { instructionsassert(condition);
S-ラングtry { instructions } catch «exception» { instructions } ... «finally { instructions?
Windows PowerShelltrap «[exception]» { instructions } ... instructions
または
try { instructions } catch «[exception]» { instructions } ... «finally { instructions
[Debug]::Assert(condition)
オブジェクティブC@throw exception;@try { instructions } @catch (exception) { instructions } ... «@finally { instructionsNSAssert(condition, description);
迅速throw exception(2.x)do { try expression ... instructions } catch exception { instructions } ...(2.x)assert(condition«, description»)
パールdie exception;eval { instructions }; if ($@) { instructions }?
try { instructions CATCH { when exception { instructions } ...}}?
ルビーraise exceptionbegin
  instructions
rescue exception
  instructions
...
«else
  instructions»
«ensure
  instructions»
end
雑談exception raiseinstructionBlock on: exception do: handlerBlockassert: conditionBlock
コモンリスプ(error "exception")
またはまたは
(error
  type
  arguments)


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

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


(check-type var type)
スキームR 6 RS(raise exception)(guard (con (condition instructions) ...) instructions)?
ISLISP(error "error-string" objects)
または
(signal-condition condition continuable)
(with-handler
  handler form*
)
?
パスカルraise Exception.Create()try Except on E: exception do begin instructions end; end;?
ビジュアルベーシック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
'*** クラスを試す *** Private mstrDescription As String Private mlngNumber As Long      Public Sub Catch ( ) mstrDescription = Err.Description mlngNumber = Err.Number End Sub         パブリックプロパティGet Number () As Long Number = mlngNumber Endプロパティ         パブリックプロパティGet Description () As String Description = mstrDescription End Property         
[12]
Debug.Assert condition
ビジュアルベーシック.NETThrow exception
または
Error errorcode
Try
  instructions
Catch« name As exception»« When condition»
  instructions
...
«Finally
  instructions»
End Try
System.Diagnostics.Debug.Assert(condition)
または
System.Diagnostics.Trace.Assert(condition)
ゾジョRaise exceptionTry
  instructions
Catch «exception»
  instructions
...
«Finally
  instructions»
End Try
パイソンraise exceptiontry:
Tab ↹instructions
except «exception»:
Tab ↹instructions
...
«else:
Tab ↹instructions»
«finally:
Tab ↹instructions»
assert condition
フォートラン
フォースcode THROWxt CATCH ( code or 0 )
OCamlraise exceptiontry expression with pattern -> expression ...assert condition
F#try expression with pattern -> expression ...
または
try expression finally expression
標準MLraise exception «arg»expression handle pattern => expression ...
ハスケルGHCthrow exception
または
throwError expression
catch tryExpression catchExpression
または
catchError tryExpression catchExpression
assert condition expression
コボルRAISE «EXCEPTION» exceptionUSE «AFTER» EXCEPTION OBJECT class-name.
またはまたはまたは
USE «AFTER» EO class-name.

USE «AFTER» EXCEPTION CONDITION exception-name «FILE file-name».

USE «AFTER» EC exception-name «FILE file-name».
さびいいえ[13]assert!(condition)
  • ^a Common Lispでは、、、を使用してwith-simple-restartrestart-caserestart-bind使用するための再起動を定義できますinvoke-restart。処理されない条件が発生すると、実装によってスタックを巻き戻す前にユーザーに再起動メニューが表示される場合があります。
  • ^b キャッチされない例外は、最も内側の動的実行に伝播されます。例外はタスク間で伝播されません(ただし、これらのタスクが現在ランデブーで同期されている場合は除きます)。

その他の制御フロー文

ブロックを終了(中断)続くラベルブランチ(gotoジェネレータからの戻り値
エイダ[1]exit «loop_name» «when condition»label:goto label
アルゴル68value exit;...do statements; skip exit; label: statements odlabel:...go to label; ...
goto label; ...
label; ...
yield(value)

コールバック[14]

APL:Leave:Continuelabel:label
または
:GoTo label
C ( C99 )break;continue;label:goto label;
オブジェクティブC
C++ (STL)
D
C#yield return value;
ジャワbreak «label»;continue «label»;
JavaScriptyield value«;»
PHPbreak «levels»;continue «levels»;goto label;yield «key =>» value;
パールlast «label»;next «label»;
行くbreak «label»continue «label»goto label
迅速break «label»continue «label»
Bashシェルbreak «levels»continue «levels»
コモンリスプ(return)
またはまたは
(return-from block)

(loop-finish)
(tagbody tag
  ...
  tag
...)
(go tag)
スキーム
ISLISP(return-from block)(tagbody tag
  ...
  tag
...)
(go tag)
パスカル(ISO)label:[あ]goto label;
パスカルFPCbreak;continue;
ビジュアルベーシックExit blockあるいは、方法については、
Return
label:GoTo label
ゾジョContinue block
ビジュアルベーシック.NETYield value
パイソンbreakcontinueyield value
RPG IVLEAVE;ITER;
S-ラングbreak;continue;
フォートランEXITCYCLElabel[b]GOTO label
ルビーbreaknext
Windows PowerShellbreak «label»continue
OCaml
F#
標準ML
ハスケルGHC
コボルEXIT PERFORMまたはEXIT PARAGRAPHまたはEXIT SECTIONまたはEXIT.EXIT PERFORM CYCLElabel «SECTION».GO TO label
  • ^a Pascalには宣言ブロックがあります。関数を参照してください。
  • ^b ラベルは 1 ~ 99999 の数字である必要があります。

文字列による関数の呼び出しと宣言については、リフレクティブ プログラミングを参照してください。

関数を呼び出す基本/void関数値を返す関数必要なメイン関数
エイダ[1]foo «(parameters)»procedure foo «(parameters)» is begin statements end foofunction foo «(parameters)» return type is begin statements end foo
アルゴル68foo «(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 }type foo(«parameters») { instructions ... return value; }«global declarations»
int main(«int argc, char *argv[]») {
  instructions
}
オブジェクティブC
C++ (STL)
ジャワpublic static void main(String[] args) { instructions }
または
public static void main(String... args) { instructions }
Dint main(«char[][] args») { instructions}
またはまたはまたは
int main(«string[] args») { instructions}

void main(«char[][] args») { instructions}

void main(«string[] args») { instructions}
C#上記と同じです。あるいは、ステートメントが 1 つだけの場合:

void foo(«parameters») => statement;

上記と同じです。あるいは、式として十分単純な場合:

void foo(«parameters») => expression;

static void Main(«string[] args») method_body
代わりに を返す場合がありますint
(C# 7.1 以降:) または を返す場合Taskがありますその場合、 になることがあります。Task<int>async
JavaScriptfunction foo(«parameters») { instructions }
またはまたは
var foo = function («parameters») { instructions }

var foo = new Function ("«parameter»", ..., "«last parameter»" "instructions");
function foo(«parameters») { instructions ... return value; }
行くfunc foo(«parameters») { instructions }func foo(«parameters») type { instructions ... return value }func main() { instructions }
迅速func foo(«parameters») { instructions }func foo(«parameters») -> type { instructions ... return value }
コモンリスプ(foo «parameters»)(defun foo («parameters»)
  instructions)

または
(setf (symbol-function 'symbol)
  function)
(defun foo («parameters»)
  ...
  value
)
スキーム(define (foo parameters) instructions)
または
(define foo (lambda (parameters) instructions))
(define (foo parameters) instructions... return_value)
または
(define foo (lambda (parameters) instructions... return_value))
ISLISP(defun foo («parameters»)
  instructions)
(defun foo («parameters»)
  ...
  value
)
パスカル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.
ビジュアルベーシックFoo(«parameters»)Sub Foo«(parameters
  instructions
End Sub
Function Foo«(parameters)»« As type»
  instructions
  Foo = value
End Function
Sub Main()
  instructions
End Sub
ビジュアルベーシック.NET上記と同じ。または、

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

がオフの場合、このAs句は不要ですOption Strict。この句の代わりに型文字を使用できますAs
戻り値が明示的に指定されていない状態で関数から制御が抜けた場合、関数は戻り値の型のデフォルト値を返します。

Sub Main(««ByVal »args() As String»)
  instructions
End Sub
または
Function Main(««ByVal »args() As String») As Integer
  instructions
End Function
ゾジョ
パイソンfoo(«parameters»)def foo(«parameters»):
Tab ↹instructions
def foo(«parameters»):
Tab ↹instructions
Tab ↹return value
S-ラングfoo(«parameters» «;qualifiers»)define foo («parameters») { instructions }define foo («parameters») { instructions ... return value; }public define slsh_main () { instructions }
フォートラン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
フォース«parameters» FOO: FOO « stack effect comment: ( before -- ) »
  instructions
;
: FOO « stack effect comment: ( before -- after ) »
  instructions
;
PHPfoo(«parameters»)function foo(«parameters») { instructions }function foo(«parameters») { instructions ... return value; }
パールfoo(«parameters»)
または
&foo«(parameters
sub foo { «my (parameters) = @_;» instructions }sub foo { «my (parameters) = @_;» instructions... «return» value; }
foo(«parameters»)
または
&foo«(parameters
«multi »sub foo(parameters) { instructions }«our «type» »«multi »sub foo(parameters) { instructions ... «return» value; }
ルビーfoo«(parametersdef foo«(parameters
  instructions
end
def foo«(parameters
  instructions
  «return» value
end
さびfoo(«parameters»)fn foo(«parameters») { instructions }fn foo(«parameters») -> type { instructions }fn main() { instructions }
スカラfoo«(parametersdef foo«(parameters)»«: Unit =» { instructions }def foo«(parameters)»«: type» = { instructions ... «return» value }def main(args: Array[String]) { instructions }
Windows PowerShellfoo «parameters»function foo { instructions };
または
function foo { «param(parametersinstructions }
function foo «(parameters)» { instructions ... return value };
または
function foo { «param(parametersinstructions ... return value }
Bashシェルfoo «parameters»function foo {
  instructions
}

または
foo () {
  instructions
}
function foo {
  instructions
  return «exit_code»
}

または
foo () {
  instructions
  return «exit_code»
}
  • パラメータ
    • $n( $1$2$3、 ...)
    • $@(すべてのパラメータ)
    • $#(パラメータの数)
    • $0(この関数名)
OCamlfoo parameterslet «rec» foo parameters = instructionslet «rec» foo parameters = instructions... return_value
F#[<EntryPoint>] let main args = instructions
標準MLfun foo parameters = ( instructions )fun foo parameters = ( instructions... return_value )
ハスケルfoo parameters = do
Tab ↹instructions
foo parameters = return_value
または
foo parameters = do
Tab ↹instructions
Tab ↹return value
«main :: IO ()»
main = do instructions
エッフェルfoo («parameters»)foo («parameters»)
  require
     preconditions
  do
     instructions
  ensure
     postconditions
  end
foo («parameters»): type
  require
     preconditions
  do
     instructions
     Result := value
  ensure
     postconditions
  end
[b]
コーヒースクリプトfoo()foo = ->foo = -> value
foo parametersfoo = () ->foo = ( parameters ) -> value
コボル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»)»
  • ^a Pascalでは前方宣言forward;に " "
  • ^b Eiffel では、アプリケーションのルート クラスと機能を指定できます。
  • ^c Fortran では、関数/サブルーチン パラメータは引数と呼ばれます (PARAMETERは言語キーワードであるため)。CALLキーワードはサブルーチンに必須です。
  • ^d を使用する代わりに"foo"、同じ値を含む文字列変数を使用することもできます。

ここで、文字列は符号付き 10 進数です。

文字列を整数に変換文字列を長整数に変換する文字列を浮動小数点数に変換する整数を文字列に変換浮動小数点から文字列へ
エイダ[1]Integer'Value (string_expression)Long_Integer'Value (string_expression)Float'Value (string_expression)Integer'Image (integer_expression)Float'Image (float_expression)
ALGOL 68の一般形式と特定形式事前の宣言および関連付け: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));
または
getf(proxy, ($dddd$, ivar));
getf(proxy, ($g$, livar));
または
getf(proxy, ($8d$, livar));
getf(proxy, ($g$, rvar));
または
getf(proxy, ($8d.4dE2d$, rvar));
putf(proxy, ($g$, ival));
または
putf(proxy, ($4d$, ival));
putf(proxy, ($g(width, places, exp)$, rval));
または
putf(proxy, ($8d.4dE2d$, rval));
APLstring_expressionstring_expressionstring_expressioninteger_expressionfloat_expression
C ( C99 )integer = atoi(string);long = atol(string);float = atof(string);sprintf(string, "%i", integer);sprintf(string, "%f", float);
オブジェクティブCinteger = [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++11integer = «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();
Dinteger = 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)
ジャワ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}`
行く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)
[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()
コモンリスプ(setf integer (parse-integer string))(setf float (read-from-string string))(setf string (princ-to-string number))
スキーム(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>))
パスカルinteger := StrToInt(string);float := StrToFloat(string);string := IntToStr(integer);string := FloatToStr(float);
ビジュアルベーシックinteger = CInt(string)long = CLng(string)float = CSng(string)
double = CDbl(string)
string = CStr(number)
Visual Basic .NET
(上記の VB 構文と右に示す .NET メソッドの両方を使用できます)
integer = Integer.Parse(string)long = Long.Parse(string)float = Single.Parse(string)
double = Double.Parse(string)
string = number.ToString()
ゾジョinteger = Val(string)long = Val(string)double = Val(string)
double = CDbl(string)
string = CStr(number)
または
string = Str(number)
パイソンinteger = int(string)long = long(string)float = float(string)string = str(number)
S-ラングinteger = atoi(string);long = atol(string);float = atof(string);string = string(number);
フォートランREAD(string,format) numberWRITE(string,format) number
PHPinteger = intval(string);
または
integer = (int)string;
float = floatval(string);
float = (float)string;
string = "$number";
またはまたは
string = strval(number);

string = (string)number;
パール[b]number = 0 + string;string = "number";
number = +string;string = ~number;
ルビーinteger = string.to_i
または
integer = Integer(string)
float = string.to_f
float = Float(string)
string = number.to_s
スカラinteger = string.toIntlong = string.toLongfloat = string.toFloatdouble = string.toDoublestring = number.toString
雑談integer := Integer readFrom: stringfloat := Float readFrom: stringstring := number asString
Windows PowerShellinteger = [int]stringlong = [long]stringfloat = [float]stringstring = [string]number;
またはまたは
string = "number";

string = (number).ToString()
OCamllet 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
標準MLval integer = Int.fromString stringval float = Real.fromString stringval string = Int.toString integerval string = Real.toString float
ハスケルGHCnumber = read stringstring = show number
コボルMOVE «FUNCTION» NUMVAL(string)[c] TO numberMOVE number TO numeric-edited
  • ^a JavaScriptは浮動小数点数のみを使用するため、技術的な問題がいくつかあります。 [7]
  • ^b Perlには別々の型はありません。文字列と数値は互換性があります。
  • ^c NUMVAL-CまたはNUMVAL-Fを の代わりに使用できますNUMVAL
  • ^ str::parse は、std::str::FromStr トレイトの実装を持つ任意の型を変換するために使用できます。 str::parsestr::parseと FromStr::from_str はResult、エラーがなければ指定された型を含む を返します。 turbofish(::<_>) は、str::parseコンテキストから型を推測できる場合は省略できます。
から読む書く
標準入力標準出力標準エラー出力
エイダ[1]Get (x)Put (x)Put (Standard_Error, x)
アルゴル68readf(($format$, x));
または
getf(stand in, ($format$, x));
printf(($format$, x));
または
putf(stand out, ($format$, x));
putf(stand error, ($format$, x));[あ]
APLx←⎕←x⍞←x
C ( C99 )scanf(format, &x);
または[b]
fscanf(stdin, format, &x);
printf(format, x);
または[c]
fprintf(stdout, format, x);
fprintf(stderr, format, x);[d]
オブジェクティブCdata = [[NSFileHandle fileHandleWithStandardInput] readDataToEndOfFile];[[NSFileHandle fileHandleWithStandardOutput] writeData:data];[[NSFileHandle fileHandleWithStandardError] writeData:data];
C++«std::»cin >> x;
または
«std::»getline(«std::»cin, str);
«std::»cout << x;«std::»cerr << x;
または
«std::»clog << x;
C#x = Console.Read();
または
x = Console.ReadLine();
Console.Write(«format, »x);
または
Console.WriteLine(«format, »x);
Console.Error.Write(«format, »x);
または
Console.Error.WriteLine(«format, »x);
Dx = std.stdio.readln()std.stdio.write(x)
またはまたはまたは
std.stdio.writeln(x)

std.stdio.writef(format, x)

std.stdio.writefln(format, x)
stderr.write(x)
またはまたはまたは
stderr.writeln(x)

std.stdio.writef(stderr, format, x)

std.stdio.writefln(stderr, format, x)
ジャワx = System.in.read();
またはまたは
x = new Scanner(System.in).nextInt();

x = new Scanner(System.in).nextLine();
System.out.print(x);
またはまたは
System.out.printf(format, x);

System.out.println(x);
System.err.print(x);
またはまたは
System.err.printf(format, x);

System.err.println(x);
行くfmt.Scan(&x)
またはまたは
fmt.Scanf(format, &x)

x = bufio.NewReader(os.Stdin).ReadString('\n')
fmt.Println(x)
または
fmt.Printf(format, x)
fmt.Fprintln(os.Stderr, x)
または
fmt.Fprintf(os.Stderr, format, x)
迅速x = readLine()(2.x)print(x)(2.x) (1.x)
println(x)
JavaScript
Webブラウザ実装
document.write(x)
JavaScript
アクティブサーバーページ
Response.Write(x)
JavaScript
Windows スクリプトホスト
x = WScript.StdIn.Read(chars)
または
x = WScript.StdIn.ReadLine()
WScript.Echo(x)
またはまたは
WScript.StdOut.Write(x)

WScript.StdOut.WriteLine(x)
WScript.StdErr.Write(x)
または
WScript.StdErr.WriteLine(x)
コモンリスプ(setf x (read-line))(princ x)
または
(format t format x)
(princ x *error-output*)
または
(format *error-output* format x)
スキームR 6 RS(define x (read-line))(display x)
または
(format #t format x)
(display x (current-error-port))
または
(format (current-error-port) format x)
ISLISP(setf x (read-line))(format (standard-output) format x)(format (error-output) format x)
パスカルread(x);
または
readln(x);
write(x);
または
writeln(x);
write(stderr, x);
または
writeln(stderr, x);
ビジュアルベーシックInput« promptxPrint x
または
? x
ビジュアルベーシック.NETx = Console.Read()
または
x = Console.ReadLine()
Console.Write(«formatx)
または
Console.WriteLine(«format, »x)
Console.Error.Write(«format, »x)
または
Console.Error.WriteLine(«format, »x)
ゾジョx = StandardInputStream.Read()
または
x = StandardInputStreame.ReadLine()
StandardOutputStream.Write(x)
または
StandardOutputStream.WriteLine(x)
StdErr.Write(x)
または
StdErr.WriteLine(x)
Python 2.xx = raw_input(«prompt»)print x
または
sys.stdout.write(x)
print >> sys.stderr, x
または
sys.stderr.write(x)
Python 3.xx = input(«prompt»)print(, end=""»)print(, end=""», file=sys.stderr)
S-ラングfgets (&x, stdin)fputs (x, stdout)fputs (x, stderr)
フォートランREAD(*,format) variable names
または[e]
READ(INPUT_UNIT,format) variable names
WRITE(*,format) expressions
または[e]
WRITE(OUTPUT_UNIT,format) expressions
WRITE(ERROR_UNIT,format) expressions[e]
フォースbuffer length ACCEPT ( # chars read )
KEY ( char )
buffer length TYPE
char EMIT
PHP$x = fgets(STDIN);
または
$x = fscanf(STDIN, format);
print x;
またはまたは
echo x;

printf(format, x);
fprintf(STDERR, format, x);
パール$x = <>;
または
$x = <STDIN>;
print x;
または
printf format, x;
print STDERR x;
または
printf STDERR format, x;
$x = $*IN.get;x.print
または
x.say
x.note
またはまたは
$*ERR.print(x)

$*ERR.say(x)
ルビーx = getsputs x
または
printf(format, x)
$stderr.puts(x)
または
$stderr.printf(format, x)
Windows PowerShell$x = Read-Host«« -Prompt» text»;
またはまたは
$x = [Console]::Read();

$x = [Console]::ReadLine()
x;
またはまたは
Write-Output x;

echo x
Write-Error x
OCamllet x = read_int ()
またはまたは
let str = read_line ()

Scanf.scanf format (fun x ... -> ...)
print_int x
またはまたは
print_endline str

Printf.printf format x ...
prerr_int x
またはまたは
prerr_endline str

Printf.eprintf format x ...
F#let x = System.Console.ReadLine()printf format x ...
または
printfn format x ...
eprintf format x ...
または
eprintfn format x ...
標準MLval str = TextIO.inputLIne TextIO.stdInprint strTextIO.output (TextIO.stdErr, str)
ハスケルGHCx <- readLn
または
str <- getLine
print x
または
putStrLn str
hPrint stderr x
または
hPutStrLn stderr str
コボルACCEPT xDISPLAY x
  • ^a ALGOL 68 には、さらに「フォーマットされていない」トランスプットルーチンread、、、、およびがwriteますgetput
  • ^b gets(x)標準入力からフォーマットされていないテキストを読み込みます。gets の使用は推奨されません。fgets(x, length, stdin)
  • ^c を puts(x)実行して、fputs(x, stdout)フォーマットされていないテキストを stdout に書き込みます。
  • ^dは fputs(x, stderr)フォーマットされていないテキストをstderrに書き込みます
  • ^e INPUT_UNIT、OUTPUT_UNIT、ERROR_UNITはISO_FORTRAN_ENVモジュールで定義されています [15]
引数の値議論の数プログラム名 / スクリプト名
エイダ[1]Argument (n)Argument_CountCommand_Name
C ( C99 )argv[n]argc最初の議論
オブジェクティブC
C++
C#args[n]args.LengthAssembly.GetEntryAssembly().Location;
ジャワargs.length
D最初の議論
JavaScript
Windows Script Host実装
WScript.Arguments(n)WScript.Arguments.lengthWScript.ScriptName
または
WScript.ScriptFullName
行くos.Args[n]len(os.Args)最初の議論
[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()
迅速Process.arguments[n]または
Process.unsafeArgv[n]
Process.arguments.countまたは
Process.argc
最初の議論
コモンリスプ???
スキームR 6 RS(list-ref (command-line) n)(length (command-line))最初の議論
ISLISP
パスカルParamStr(n)ParamCount最初の議論
ビジュアルベーシックCommand[b]App.Path
ビジュアルベーシック.NETCmdArgs(n)CmdArgs.Length[Assembly].GetEntryAssembly().Location
ゾジョSystem.CommandLine(文字列解析)Application.ExecutableFile.Name
パイソンsys.argv[n]len(sys.argv)最初の議論
S-ラング__argv[n]__argc最初の議論
フォートラン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]$argc最初の議論
Bashシェル$n ($1, $2, $3, ...)
$@(すべての引数)
$#$0
パール$ARGV[n]scalar(@ARGV)$0
@*ARGS[n]@*ARGS.elems$PROGRAM_NAME
ルビーARGV[n]ARGV.size$0
Windows PowerShell$args[n]$args.Length$MyInvocation.MyCommand.Name
OCamlSys.argv.(n)Array.length Sys.argv最初の議論
F#args.[n]args.LengthAssembly.GetEntryAssembly().Location
標準MLList.nth (CommandLine.arguments (), n)length (CommandLine.arguments ())CommandLine.name ()
ハスケルGHCdo { args <- System.getArgs; return length args !! n}do { args <- System.getArgs; return length args}System.getProgName
コボル[c]
  • ^a Rust では、std::env::argsそれぞれstd::env::args_os反復子、 を返しますは各引数を に変換し、 UTF-8に変換できない引数に達するとパニックになりますオペレーティング システム ( ) からの生の文字列の非損失表現を返しますが、これは無効な UTF-8 である可能性があります。std::env::Argsstd::env::ArgsOsArgsStringArgsOsstd::ffi::OsString
  • ^b Visual Basicでは、コマンドライン引数は分割されません。分割するにはsplit関数が必要ですSplit(string)
  • ^c COBOL 標準にはコマンドライン引数にアクセスする手段は含まれていませんが、それらにアクセスするための一般的なコンパイラ拡張機能には、メインプログラムのパラメータの定義やACCEPTステートメントの使用が含まれます。

コマンドの実行

シェルコマンドプログラムを実行する現在のプログラムを新しく実行されたプログラムに置き換える
エイダ[1]言語標準の一部ではありません。コンパイラが提供するパッケージ、またはCやPOSIXとのインターフェースによって行われるのが一般的です[16]
Csystem("command");execl(path, args);
または
execv(path, arglist);
C++
オブジェクティブC[NSTask launchedTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)arguments];
C#System.Diagnostics.Process.Start(path, argstring);
F#
行くexec.Run(path, argv, envv, dir, exec.DevNull, exec.DevNull, exec.DevNull)os.Exec(path, argv, envv)
ビジュアルベーシックInteraction.Shell(command «, WindowStyle» «, isWaitOnReturn»)
ビジュアルベーシック.NETMicrosoft.VisualBasic.Interaction.Shell(command «, WindowStyle» «, isWaitOnReturn»)System.Diagnostics.Process.Start(path, argstring)
ゾジョShell.Execute(command «, Parameters»)FolderItem.Launch(parameters, activate)
Dstd.process.system("command");std.process.execv(path, arglist);
ジャワRuntime.exec(command);
または
new ProcessBuilder(command).start();
JavaScript
Windows Script Host実装
WScript.CreateObject ("WScript.Shell").Run(command «, WindowStyle» «, isWaitOnReturn»);WshShell.Exec(command)
コモンリスプ(uiop:run-program command)
スキーム(system command)
ISLISP
パスカルsystem(command);
OCamlSys.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
または
Unix.execve prog args env
標準MLOS.Process.system commandUnix.execute (path, args)Posix.Process.exec (path, args)
ハスケルGHCSystem.system commandSystem.Process.runProcess path args ...Posix.Process.executeFile path True args ...
パールsystem(command)
またはまたは
$output = `command`

$output = qx(command)
exec(path, args)
ルビーsystem(command)
または
output = `command`
exec(path, args)
PHPsystem(command)
またはまたはまたは
$output = `command`

exec(command)

passthru(command)
パイソンos.system(command)
または
subprocess.Popen(command)
subprocess.call(["program", "arg1", "arg2", ...])os.execv(path, args)
S-ラングsystem(command)
フォートランCALL EXECUTE_COMMAND_LINE (COMMAND «, WAIT» «, EXITSTAT» «, CMDSTAT» «, CMDMSG»)[あ]
Windows PowerShell[Diagnostics.Process]::Start(command)«Invoke-Item »program arg1 arg2 ...
Bashシェルoutput=`command`
または
output=$(command)
program arg1 arg2 ...

^a Fortran 2008以降。 [17]

参照

参考文献

  1. ^ abcdefghijklmnop Adaリファレンスマニュアル – 言語および標準ライブラリ; ISO/IEC 8652:201x (E)、「リファレンスマニュアル」(PDF) 。 2011年4月27日時点のオリジナル(PDF)からアーカイブ。 2013年7月19日閲覧
  2. ^ "Common Lisp HyperSpec (TM)". lispworks.com . 2017年1月30日閲覧
  3. ^ "www.islisp.info: 仕様". islisp.info . 2016年1月22日時点のオリジナルよりアーカイブ2017年1月30日閲覧。
  4. ^ ab "Selected_int_kind in Fortran Wiki". fortranwiki.org . 2017年1月30日閲覧
  5. ^ 「Erlang — 型と関数の仕様」erlang.org . 2017年1月30日閲覧
  6. ^ 「Erlang — 上級編」erlang.org . 2017年1月30日閲覧
  7. ^ ab 8.5 数値型
  8. ^ ab "Selected_real_kind in Fortran Wiki". fortranwiki.org . 2017年1月30日閲覧
  9. ^ 「GNU Cライブラリ:複素数」gnu.org . 2017年1月30日閲覧
  10. ^ “Grammar vb”. Visual Basic Language Specification . 2016年6月17日. 2019年8月29日時点のオリジナルよりアーカイブ。 2019年8月29日閲覧
  11. ^ "for...of". mozilla.org . 2017年1月30日閲覧
  12. ^ “Try-Catch for VB”. google.com . 2016年4月16日時点のオリジナルよりアーカイブ2017年1月30日閲覧。
  13. ^ Klabnik, Steve; Nichols, Carol. 「エラー処理」. Rustプログラミング言語.
  14. ^ 「素数分解 – Rosetta Code」. rosettacode.org . 2017年1月30日閲覧
  15. ^ 「Fortran Wikiのiso_fortran_env」. fortranwiki.org . 2017年1月30日閲覧
  16. ^ 「システムコマンドの実行 – Rosetta Code」. rosettacode.org . 2017年1月30日閲覧
  17. ^ 「EXECUTE_COMMAND_LINE – GNU Fortranコンパイラ」. gnu.org . 2017年1月30日閲覧
Retrieved from "https://en.wikipedia.org/w/index.php?title=Comparison_of_programming_languages_(basic_instructions)&oldid=1314429862"