프로그래밍 언어 비교(기본 지침)
Comparison of programming languages (basic instructions)비교 프로그래밍 언어 |
---|
|
이 문서에서는 다수의 프로그래밍 언어를 데이터 유형, 표현식, 스테이트먼트 및 선언 구문 및 몇 가지 일반적인 운영 체제인터페이스를 표로 작성하여 비교합니다.
이 문서의 표기법
일반적으로, var,var, 또는var는, 판독기에 의해서 해석되는 변수명 또는 그 외의 비문자의 값이 어떻게 표현되는 방법입니다.나머지는 문자 그대로의 코드입니다.Guillemets(길레메츠)«
그리고.»
)는 옵션의 섹션을 포함합니다. Tab ↹ 에, 필요한(공백) 들여쓰기를 나타냅니다.
테이블은 기본적으로 프로그래밍 언어 이름에 따라 사전 편집적으로 오름차순으로 정렬되지 않으며 일부 프로그래밍 언어에는 일부 테이블에 엔트리가 있지만 다른 테이블에는 없습니다.
유형 식별자
정수
8 비트(바이트) | 16비트(짧은 정수) | 32비트 | 64비트(긴 정수) | 단어 크기 | 임의 정밀도(bignum) | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
서명된 | 서명 없음 | 서명된 | 서명 없음 | 서명된 | 서명 없음 | 서명된 | 서명 없음 | 서명된 | 서명 없음 | ||
아다[1] | range -2**7 .. 2**7 - 1 [j] | range 0 .. 2**8 - 1 [j]또는mod 2**8 [k] | range -2**15 .. 2**15 - 1 [j] | range 0 .. 2**16 - 1 [j]또는mod 2**16 [k] | range -2**31 .. 2**31 - 1 [j] | range 0 .. 2**32 - 1 [j]또는mod 2**32 [k] | range -2**63 .. 2**63 - 1 [j] | mod 2**64 [k] | Integer [j] | range 0 .. 2**Integer' [j]또는mod Integer' [k] | — |
알골 68(variable-width) | short short int [c] | — | short int [c] | — | int [c] | — | long int [c] | — | int [c] | — | long long int [a][g] |
bytes 그리고.bits | |||||||||||
C(C99 고정폭) | int8_t | uint8_t | int16_t | uint16_t | int32_t | uint32_t | int64_t | uint64_t | intptr_t [c] | size_t [c] | — |
C++(C++11 고정폭) | |||||||||||
C(C99 가변폭) | signed char | unsigned char | short [c] | unsigned short [c] | long [c] | unsigned long [c] | long long [c] | unsigned long long [c] | int [c] | unsigned int [c] | |
C++(C++11 가변폭) | |||||||||||
목표-C(코코아) | signed char 또는int8_t | unsigned char 또는uint8_t | short 또는int16_t | unsigned short 또는uint16_t | int 또는int32_t | unsigned int 또는uint32_t | long long 또는int64_t | unsigned long long 또는uint64_t | NSInteger 또는long | NSUInteger 또는unsigned long | |
C# | sbyte | byte | short | ushort | int | uint | long | ulong | IntPtr | UIntPtr | System.Numerics. (.NET 4.0) |
자바 | byte | — | char [b] | — | — | — | — | java.math. | |||
가세요 | int8 | uint8 또는byte | int16 | uint16 | int32 | uint32 | int64 | uint64 | int | uint | big.Int |
녹 | i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64 | isize | usize | — |
재빠르다 | Int8 | UInt8 | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 | Int | UInt | |
D | byte | ubyte | short | ushort | int | uint | long | ulong | — | — | BigInt |
일반적인 리스프[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 | ||||||||||
Pascal (FPC) | shortint | byte | smallint | word | longint | longword | int64 | qword | integer | cardinal | — |
비주얼 베이직 | — | Byte | Integer | — | Long | — | — | — | — | ||
Visual Basic.그물 | SByte | Short | UShort | Integer | UInteger | Long | ULong | System.Numerics (.NET 4.0) | |||
FreeBasic | Byte 또는Integer<8> | UByte 또는UInteger<8> | Short 또는Integer<16> | UShort 또는UInteger<16> | Long 또는Integer<32> | ULong 또는UInteger<32> | LongInt 또는Integer<64> | ULongInt 또는UInteger<64> | Integer | UInteger | — |
파이썬 2.x | — | — | — | — | int | — | long | ||||
파이썬 3.x | — | — | — | — | — | int | |||||
S랑 | — | — | — | — | — | — | |||||
포트란 | INTEGER [f] | — | INTEGER [f] | — | INTEGER [f] | — | INTEGER [f] | — | |||
PHP | — | — | int [m] | — | int [m] | — | — | [e] | |||
Perl 5 | --[d] | --[d] | --[d] | --[d] | --[d] | Math::BigInt | |||||
라쿠 | int8 | uint8 | int16 | uint16 | int32 | uint32 | int64 | uint64 | Int | — | |
루비 | — | — | — | — | Fixnum | — | Bignum | ||||
얼랑[n] | — | — | — | — | integer() | — | integer() [o] | ||||
스칼라 | Byte | — | Short | Char [l] | Int | — | Long | — | — | — | scala.math.BigInt |
시드7 | — | — | — | — | — | — | integer | — | — | — | bigInteger |
스몰토크 | — | — | — | — | SmallInteger [i] | — | LargeInteger [i] | ||||
Windows PowerShell | — | — | — | — | — | — | |||||
OCaml | — | — | int32 | — | int64 | — | int 또는nativeint | open Big_int;; 또는big_int | |||
F# | sbyte | byte | int16 | uint16 | int32 또는int | uint32 | uint64 | nativeint | unativeint | bigint | |
표준 ML | — | Word8.word | — | Int32.int | Word32.word | Int64.int | Word64.word | int | word | LargeInt.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» 또는Word64 | Int | «import Word» 또는Word | Integer |
에펠 | INTEGER_8 | NATURAL_8 | INTEGER_16 | NATURAL_16 | INTEGER_32 | NATURAL_32 | INTEGER_64 | NATURAL_64 | INTEGER | NATURAL | — |
코볼[h] | BINARY-CHAR «SIGNED» | BINARY-CHAR UNSIGNED | BINARY-SHORT «SIGNED» | BINARY-SHORT UNSIGNED | BINARY-LONG «SIGNED» | BINARY-LONG UNSIGNED | BINARY-DOUBLE «SIGNED» | BINARY-DOUBLE UNSIGNED | — | — | — |
매스매티카 | — | — | — | — | — | Integer | |||||
울프람어 | — | — | — | — | — | Integer |
- ^a 표준 상수
int shorts
그리고.int lengths
몇 개인지 판단하기 위해 사용할 수 있다short
및long
는, 프리픽스를 유효하게 부가할 수 있습니다.short int
그리고.long int
의 실제 크기short int
,int
,그리고.long int
상수로 사용할 수 있습니다.short max int
,max int
,그리고.long max int
기타. - ^b 일반적으로 문자에 사용됩니다.
- ^c ALGOL 68, C 및 C++ 언어는 정수 유형의 정확한 폭을 지정하지 않습니다.
short
,int
,long
, 및 (C99, C++11)long long
구현에 의존합니다.C 및 C++의 경우short
,long
,그리고.long long
타입은 각각 16비트, 32비트 및 64비트 이상이어야 하지만 그 이상의 폭을 가질 수 있습니다.그int
type은 최소 와이드여야 합니다.short
최대 폭은long
는 일반적으로 머신의 프로세서에서 워드 사이즈의 폭입니다(32비트 머신의 경우 32비트, 64비트 머신의 경우 64비트 폭).또한 C99 및 C[citation needed]++11은[u]intN_t
stdint.h 헤더의 exact-width 타입.'C 구문 번호' 참조자세한 내용은 필수 유형입니다.또, 타입size_t
그리고.ptrdiff_t
는 배열 인덱스를 처리할 수 있을 만큼 충분히 큰 부호 없는 정수와 부호 있는 정수를 유지하는 주소 크기 및 포인터 간의 차이와 관련하여 정의됩니다. - ^d Perl 5에는 다른 유형이 없습니다.정수, 부동 소수점 숫자, 문자열 등은 모두 "스칼라"로 간주됩니다.
- ^e PHP에는 2개의 임의 정밀도 라이브러리가 있습니다.BCMath 라이브러리는 데이터 유형으로 문자열을 사용합니다.GMP 라이브러리는 내부 "리소스" 유형을 사용합니다.
- ^f 값
n
에 의해 제공됩니다.SELECTED_INT_KIND
[4] 본질적 기능 - ^GALGOL 68G 런타임 옵션
--precision "number"
정밀도를 설정할 수 있다long long int
필요한 유효 자리수까지를 지정합니다.표준 상수long long int width
그리고.long long max int
를 사용하여 실제 정밀도를 확인할 수 있습니다. - ^hCOBOL은 필요한 정밀도를 지정할 수 있으며 지정된 정밀도를 나타낼 수 있는 사용 가능한 유형을 자동으로 선택합니다."
PIC S9999
예를 들어 소수점 이하 4자리 정밀도의 부호 있는 변수가 필요합니다.이진 필드로 지정하면 대부분의 플랫폼에서 16비트 서명 유형이 선택됩니다. - ^iSmalltalk는 자동으로 정수 표현을 선택합니다.일반적으로 두 가지 표현이 있습니다. 하나는 네이티브 워드 크기에서 태그 비트를 뺀 정수입니다.SmallInteger) 및 임의의 크기의 정수(LargeInteger)를 지원하는 것.산술 연산은 다형 인수를 지원하며 가장 적절한 콤팩트한 표현으로 결과를 반환합니다.
- ^jAda 범위 유형은 런타임(및 정적 표현에 대한 컴파일 시간)에 경계 위반 여부를 확인합니다.런타임 경계 위반은 "제약 오류" 예외를 발생시킵니다.범위는 2의 거듭제곱으로 제한되지 않습니다.일반적으로 사전 정의된 정수 서브타입은 다음과 같습니다.양수(
range 1 .. Integer'Last
및 내추럴 ( )range 0 .. Integer'Last
).Short_Short_Integer
(8비트),Short_Integer
(16비트) 및Long_Integer
(64비트)도 일반적으로 미리 정의되어 있지만 Ada 표준에서는 필요하지 않습니다.성능이 무결성 검사보다 더 중요한 경우 런타임 검사를 사용하지 않도록 설정할 수 있습니다. - ^k Ada modulo 유형은 모든 연산에 모듈로 산술을 구현합니다. 즉, 범위 위반은 불가능합니다.모듈로는 2승으로 제한되지 않는다.
- ^l Java의 char와 같은 문자에 일반적으로 사용됩니다.
- ^m
int
PHP의 너비는 다음과 같습니다.long
를 입력합니다.[c] - ^n Erlang은 동적으로 입력됩니다.유형 식별자는 보통 레코드 필드의 유형, 함수의 [5]인수 및 반환 유형을 지정하기 위해 사용됩니다.
- ^o 1글자를 [6]넘었을 때.
부동 소수점
단일 정밀도 | 2배 정밀도 | 기타 정밀도 | 프로세서에 의존하다 | |
---|---|---|---|---|
아다[1] | Float | Long_Float | — | |
알골 68 | real [a] | long real [a] | short real ,long long real 등[d] | |
C | float [b] | double | long double [f] | |
C++(STL) | ||||
목표-C(코코아) | CGFloat | |||
C# | float | — | ||
자바 | ||||
가세요 | float32 | float64 | ||
녹 | f32 | f64 | ||
재빠르다 | Float 또는Float32 | Double 또는Float64 | Float80 [g] | CGFloat |
D | float | double | real | |
일반적인 리스프 | single-float | double-float | float, short-float, long-float | |
스킴 | ||||
ISLISP | ||||
Pascal (FPC) | single | double | real | |
비주얼 베이직 | Single | Double | — | |
Visual Basic.그물 | ||||
조조 | ||||
파이썬 | — | float | ||
자바스크립트 | Number [7] | — | ||
S랑 | ||||
포트란 | REAL(KIND = n) [c] | |||
PHP | float | |||
펄 | ||||
라쿠 | num32 | num64 | Num | |
루비 | — | Float | — | |
스칼라 | Float | Double | ||
시드7 | — | float | ||
스몰토크 | Float | Double | ||
Windows PowerShell | ||||
OCaml | — | float | — | |
F# | float32 | |||
표준 ML | — | real | ||
하스켈(GHC) | Float | Double | ||
에펠 | REAL_32 | REAL_64 | ||
코볼 | FLOAT-BINARY-7 [e] | FLOAT-BINARY-34 [e] | FLOAT-SHORT ,FLOAT-LONG ,FLOAT-EXTENDED | |
매스매티카 | — | — | Real |
- ^a 표준 상수
real shorts
그리고.real lengths
몇 개인지 판단하기 위해 사용할 수 있다short
및long
는, 프리픽스를 유효하게 부가할 수 있습니다.short real
그리고.long real
의 실제 크기short real
,real
,그리고.long real
상수로 사용할 수 있습니다.short max real
,max real
그리고.long max real
등. 상수가 있는 경우short small real
,small real
그리고.long small real
각 타입의 머신 엡실론에서 사용할 수 있습니다. - ^b 단일 정밀도의 선언은 종종 받아들여지지 않는다.
- ^c 값
n
에 의해 제공됩니다.SELECTED_REAL_KIND
[8] 본질적 기능 - ^dALGOL 68G 런타임 옵션
--precision "number"
정밀도를 설정할 수 있다long long real
필요한 유효 자리수까지를 지정합니다.표준 상수long long real width
그리고.long long max real
를 사용하여 실제 정밀도를 확인할 수 있습니다. - ^e 이러한 IEEE 부동소수점 유형은 다음 COBOL 표준에서 도입될 예정입니다.
- ^f 와 같은 크기
double
많은 구현에 사용됩니다. - ^g Swift는 80비트 확장 정밀도 부동소수점 유형을 지원하며, 이는 다음과 같습니다.
long double
C언어로 되어 있습니다.
복소수
정수 | 단일 정밀도 | 2배 정밀도 | 반정밀, 4정밀 등 | |
---|---|---|---|---|
아다[1] | — | Complex [b] | Complex [b] | Complex [b] |
알골 68 | — | compl | long compl 기타. | short compl 기타.long long compl 기타. |
C(C99)[9] | — | float complex | double complex | — |
C++(STL) | — | std::complex<float> | std::complex<double> | |
C# | — | — | System.Numerics.Complex (.NET 4.0) | |
자바 | — | — | — | |
가세요 | — | complex64 | complex128 | |
D | — | cfloat | cdouble | |
목표-C | — | — | — | |
일반적인 리스프 | (복소 정수) | (복잡한 싱글 소켓) | (복잡한 복층) | 복잡한 |
스킴 | — | |||
파스칼 | — | — | ||
비주얼 베이직 | — | — | ||
Visual Basic.그물 | — | — | System.Numerics.Complex (.NET 4.0) | |
펄 | Math::Complex | |||
라쿠 | complex64 | complex128 | Complex | |
파이썬 | complex | — | ||
자바스크립트 | — | — | ||
S랑 | — | — | ||
포트란 | COMPLEX(KIND = n) [a] | |||
루비 | Complex | — | Complex | |
스칼라 | — | — | — | |
시드7 | — | — | complex | |
스몰토크 | Complex | Complex | Complex | |
Windows PowerShell | — | — | ||
OCaml | — | — | Complex.t | |
F# | System.Numerics.Complex (.NET 4.0) | |||
표준 ML | — | — | — | |
하스켈(GHC) | — | Complex.Complex Float | Complex.Complex Double | |
에펠 | — | — | — | |
코볼 | — | — | — | |
매스매티카 | Complex | — | — | Complex |
기타 변수 유형
본문 | 부울 | 열거 | 오브젝트/범용 | ||
---|---|---|---|---|---|
성격 | 스트링[a] | ||||
아다[1] | Character | String ,Bounded_String ,Unbounded_String | Boolean | (item1, item2, ...) | tagged null record |
알골 68 | char | string ,bytes | bool ,bits | - 사용자 정의 | — |
C(C99) | char ,wchar_t | — | bool [b] | enum «name» { item1, item2, ... }; | void * |
C++(STL) | «std::»string | ||||
목표-C | unichar | NSString * | BOOL | id | |
C# | char | string | bool | enum name { item1« = value», item2« = value», ... } | 물건 |
자바 | String | boolean | enum name { item1, item2, ... } | Object | |
가세요 | byte ,rune | string | bool | const ( | interface{} |
녹 | char | String | bool | enum name { item1« = value», item2« = value», ... } | std::any::Any |
재빠르다 | Character | String | Bool | enum name { case item1, item2, ... } | Any |
D | char | string | bool | enum name { item1, item2, ... } | std.variant.Variant |
일반적인 리스프 | character | string | boolean | (member item1 item2 ...) | t |
스킴 | |||||
ISLISP | |||||
Pascal (ISO) | char | — | boolean | ( item1, item2, ... ) | — |
오브젝트 파스칼(델파이) | string | variant | |||
비주얼 베이직 | — | String | Boolean | Enum name | [[Variant type Variant]] |
Visual Basic.그물 | Char | Object | |||
조조 | — | Object 또는Variant | |||
파이썬 | --[d] | str | bool | from enum import Enum | object |
자바스크립트 | --[d] | String | Boolean | Object | |
S랑 | |||||
포트란 | CHARACTER(LEN = *) | CHARACTER(LEN = :), allocatable | LOGICAL(KIND = n) [f] | CLASS(*) | |
PHP | --[d] | string | bool | (유형 선언 생략) | |
펄 | --[d] | UNIVERSAL | |||
라쿠 | Char | Str | Bool | enum name<item1 item2 ...> enum name <<:item1(value) :item2(value) ..>> | Mu |
루비 | --[d] | String | Object [c] | Object | |
스칼라 | Char | String | Boolean | object name extends Enumeration { | Any |
시드7 | char | string | boolean | const type: name is new enum | |
Windows PowerShell | |||||
OCaml | char | string | bool | --[e] | — |
F# | type name = item1 = value item2 = value ... | obj | |||
표준 ML | --[e] | — | |||
하스켈(GHC) | Char | String | Bool | --[e] | — |
에펠 | CHARACTER | STRING | BOOLEAN | — | ANY |
코볼 | PIC X | PIC X(string length) 또는PIC X«X...» | PIC 1«(number of digits)» 또는PIC 1«1...» | — | OBJECT REFERENCE |
매스매티카 | --[d] | String | — |
- ^a 구체적으로 임의의 길이의 문자열로 자동으로 관리됩니다.
- ^b 이 언어는 부울을 정수로 나타냅니다.false는 0의 값으로, true는 0이 아닌 값으로 나타냅니다.
- ^c 모든 값은 true 또는 false로 평가됩니다.의 모든 것은 true로 평가되고 의 모든 것은 false로 평가됩니다.
- ^d 이 언어에는 별도의 문자 유형이 없습니다.문자는 길이 1의 문자열로 표시됩니다.
- ^e 이 언어의 열거는 null 생성자만 있는 대수형입니다.
- ^f 값은 에 의해 제공됩니다.
SELECTED_INT_KIND
[4] 본질적 기능
파생형
어레이
고정 크기 배열 | 동적 크기 배열 | |||
---|---|---|---|---|
일차원 배열 | 다차원 배열 | 일차원 배열 | 다차원 배열 | |
아다[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] 또는 단순하게: [size] | [first1:last1, first2:last2] 또는 [first1:last1][first2:last2] 기타. | flex[first:last] 또는 단순하게: flex[size] | flex[first1:last1, first2:last2] 또는 flex[first1:last1] |
C(C99) | type name[size] [a] | type name[size1][size2] [a] | type *name 또는 블록 내: int n = ...; type name[n] | |
C++(STL) | «std::»array<type, size> (C++11) | «std::»vector<type> | ||
C# | type[] | type[,,...] | System 또는 System | |
자바 | type[] [b] | type[][]... [b] | ArrayList or ArrayList<type> | |
D | type[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>> | ||
목표-C | NSArray | NSMutableArray | ||
자바스크립트 | — | — | Array [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]또는 array[first1..last1, first2..last2, ...] of type [c] | — | — |
오브젝트 파스칼(델파이) | array of type | array of array ... of type | ||
비주얼 베이직 | Dim x(last) As type | Dim x(last1, last2,...) As type | ||
Visual Basic.그물 | type() | type(,,...) | System 또는 System | |
파이썬 | list | |||
S랑 | x = type[size]; | x = type[size1, size2, ...]; | ||
포트란 | type :: name(size) | type :: name(size1, size2,...) | type, ALLOCATABLE :: name(:) | type, ALLOCATABLE :: name(:,:,...) |
PHP | array | |||
펄 | ||||
라쿠 | Array[type] or Array of type | |||
루비 | x = Array.new(size1){ Array.new(size2) } | Array | ||
스칼라 | Array[type] | Array[...[Array[type]]...] | ArrayBuffer[type] | |
시드7 | array 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 |
스몰토크 | Array | OrderedCollection | ||
Windows PowerShell | type[] | type[,,...] | ||
OCaml | type array | type array ... array | ||
F# | type [] 또는 type array | type [,,...] | System 또는 System | |
표준 ML | type vector or type array | |||
하스켈(GHC) | x = Array.array (0, size-1) list_of_association_pairs | x = 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 대부분의 표현(단,
sizeof
그리고.&
연산자), C의 배열 유형 값이 첫 번째 인수의 포인터로 자동 변환됩니다.구문 및 포인터 조작에 대한 자세한 내용은 C 구문 #Arrays를 참조하십시오. - ^b C라이크
type x[]
단, Java에서는 동작합니다.type[] x
는 어레이 선언의 바람직한 형식입니다. - ^c 하위 범위는 배열의 경계를 정의하는 데 사용됩니다.
- ^d JavaScript의 배열은 특별한 종류의 객체입니다.
- ^e The
DEPENDING ON
COBOL의 절은 진정한 가변 길이 배열을 생성하지 않으며 항상 배열의 최대 크기를 할당합니다.
기타 타입
단순 복합형 | 대수 데이터형 | 유니언 | ||
---|---|---|---|---|
기록. | 태플식 | |||
아다[1] | type name is «abstract» «tagged» «limited» [record | — | 레코드, 유니언 및 열거의 임의의 조합(재귀 타입을 유효하게 하는 것에 대한 참조도 포함한다). | type name (variation : discrete_type) is record |
알골 68 | struct (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] | |||
자바스크립트 | — | |||
D | struct name {type name;...} | std.variant.Algebraic!(type,...) | union {type name;...} | |
가세요 | struct { | |||
녹 | struct name {name: type, ...} | (val1, val2, ... ) | enum name { Foo(types), ...} | union name {name: type, ...} |
재빠르다 | struct name { | («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 | — | — | record |
비주얼 베이직 | ||||
Visual Basic.그물 | Structure name | (val1, val2, ... ) | ||
파이썬 | --[a] | «(»val1, val2, val3, ... «)» | — | |
S랑 | struct {name [=value], ...} | |||
포트란 | TYPE name | |||
PHP | --[a] | |||
펄 | --[d] | — | ||
라쿠 | --[a] | |||
루비 | OpenStruct.new({:name => value}) | |||
스칼라 | case class name(«var» name: type, ...) | (val1, val2, val3, ... ) | abstract class name 또는 abstract class name 또는 케이스 클래스와 케이스 오브젝트의 조합 | |
Windows PowerShell | ||||
OCaml | type name = {«mutable» name : type;...} | «(»val1, val2, val3, ... «)» | type name = Foo «of type» Bar «of type» ... | — |
F# | ||||
표준 ML | type 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. | — | — | name REDEFINES variable type. |
- ^a 클래스만 지원됩니다.
- ^b
struct
C++ 의 는 실제로는 클래스이지만, 디폴트의 퍼블릭 가시성이 있어 POD 오브젝트이기도 합니다.C++11은 이를 더욱 확장하여 클래스가 POD 객체와 동일하게 동작하도록 했습니다. - ^c 쌍만
- ^d Perl에는 레코드가 없지만 Perl의 유형 시스템에서는 여러 데이터 유형을 배열에 포함할 수 있기 때문에 변수 인덱스가 없는 "해시"(관련 배열)는 레코드와 사실상 동일합니다.
- ^e 이 언어의 열거는 null 생성자만 있는 대수형입니다.
변수 및 상수 선언
변수 | 일정한 | 형식 동의어 | |
---|---|---|---|
아다[1] | identifier : type« := initial_value» [e] | identifier : constant type := final_value | subtype identifier is type |
알골 68 | modename 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; |
D | type 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; | — |
자바스크립트 | var name« = initial_value»; 또는let name« = initial_value»; (ECMAScript 2015 이후) | const name = value; (ECMAScript 2015 이후) | |
가세요 | var name type« = initial_value» 또는 name := initial_value | const name «type» = value | type synonym type |
녹[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» = value | typealias 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 = value | synonym = type |
비주얼 베이직 | Dim name «As type» | 왼쪽의 주를 참조하십시오. 상수는 동일한 구문을 사용합니다.
| |
Visual Basic.그물[10] | VB의 변수 선언 구문.NET은 매우 정확하게 묘사하기 어렵다. 식별자 서픽스("수식자")가 존재하는 경우:
그리고 그것
유효한 선언문은 다음과 같은 형식이다.
그리고 각각을 위해
한다면 | Imports synonym = type | |
조조 | Dim name «As type»« = initial_value» | — | |
파이썬 | name«: type» = initial_value | — | synonym = type [b] |
커피 스크립트 | name = initial_value | ||
S랑 | name = initial_value; | typedef struct {...} typename | |
포트란 | 유형명 | type, PARAMETER :: name = value | |
PHP | $name = initial_value; | define("name", value); | — |
펄 | «my» $name« = initial_value»; [c] | use constant name => value; | |
라쿠 | «my «type»» $name« = initial_value»; [c] | «my «type»» constant name = value; | ::synonym ::= type |
루비 | name = initial_value | Name = value | synonym = type [b] |
스칼라 | var name«: type» = initial_value | val name«: type» = value | type synonym = type |
Windows PowerShell | «[type]» $name = initial_value | — | — |
배쉬 셸 | name=initial_value | — | — |
OCaml | let name« : type ref» = ref value [d] | let name «: type» = value | type synonym = type |
F# | let mutable name «: type» = value | ||
표준 ML | val name «: type ref» = ref value [d] | val name «: type» = value | |
하스켈 | «name::type;» name = value | type Synonym = type | |
넷째 | VARIABLE name (일부 시스템에서는value VARIABLE name 대신) | value 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 기술적으로 이것은 이름이 가변 변수임을 선언하지 않습니다.ML에서는 모든 이름을 한 번만 바인딩할 수 있습니다. 대신 단순한 가변 셀인 "참조" 데이터 구조를 가리키기 위해 이름을 선언합니다.그런 다음 데이터 구조를 읽고 쓸 수 있습니다.
!
그리고.:=
연산자를 지정합니다. - ^e 초기값이 지정되지 않은 경우 비활성값이 자동으로 할당됩니다(유효값이 할당되기 전에 사용된 경우 런타임 예외가 트리거됩니다).이 동작은 억제할 수 있지만 예측 가능성을 위해 권장된다.유형에 대해 유효하지 않은 값을 찾을 수 없는 경우(예: 비정상 정수 유형의 경우) 대신 유효하지만 예측 가능한 값이 선택됩니다.
- ^f Rust에서 초기값이 지정되지 않은 경우
let
또는let mut
변수를 나중에 할당하지 않으면 "변수 변경" 경고가 발생합니다.값이 지정되지 않은 경우const
또는static
또는static mut
variable, 오류가 있습니다.대소문자가 아닌 경우 "대소문자가 아닌 글로벌" 오류가 있습니다.const
변수입니다.정의 후,static mut
변수를 할당할 수 있는 것은,unsafe
블록 또는 기능.
흐름 제어
조건문
한다면 | 그렇지 않으면 | 엄선된 케이스 | 조건식 | |
---|---|---|---|---|
아다[1] | if condition then | if condition1 then | case expression is | (if condition1 then 또는 (case expression is |
시드7 | if condition then | if condition1 then | case expression of | |
모듈라-2 | if condition then | if condition1 then | case expression of | |
알골 68 | if condition then statements «else statements» fi | if condition then statements elif condition then statements fi | case switch in statements, statements«,... out statements» esac | ( condition valueIfTrue valueIfFalse ) |
알골 68 (형식) | ( condition statements « statements» ) | ( condition statements : condition statements ) | ( variable statements,... « statements» ) | |
APL | :If condition | :If condition | :Select expression | {condition:valueIfTrue ⋄ valueIfFalse} |
C(C99) | if (condition) instructions instructions 는 다음 형식의 단일 문 또는 블록일 수 있습니다.{ statements } | if (condition) instructions 또는 if (condition) instructions | switch (variable) { | condition ? valueIfTrue : valueIfFalse |
목표-C | ||||
C++(STL) | ||||
D | ||||
자바 | ||||
자바스크립트 | ||||
PHP | ||||
C# | if (condition) instructions
| if (condition) instructions | switch (variable) 공백이 아닌 모든 케이스는 다음 문자로 끝나야 합니다. | condition ? valueIfTrue : valueIfFalse |
Windows PowerShell | if (condition) instruction | if (condition) { instructions } | switch (variable) { case1{instructions «break;» } ... «default { instructions }»} | |
가세요 | if condition {instructions} | if condition {instructions} 또는 switch { | switch variable { | |
재빠르다 | if condition {instructions} | if condition {instructions} | switch variable { | |
펄 | if (condition) {instructions} 또는 unless (notcondition) {instructions} | if (condition) {instructions} 또는 unless (notcondition) {instructions} | use feature "switch"; | condition ? valueIfTrue : valueIfFalse |
라쿠 | if condition {instructions} 또는 unless notcondition {instructions} | if condition {instructions} | given variable { | condition ?? valueIfTrue !! valueIfFalse |
루비 | if condition | if condition | case variable | condition ? valueIfTrue : valueIfFalse |
스칼라 | if (condition) {instructions} | if (condition) {instructions} | expression match { [b] | if (condition) valueIfTrue else valueIfFalse |
스몰토크 | condition ifTrue: | condition ifTrue: trueBlock ifFalse: falseBlock | ||
일반적인 리스프 | (when condition 또는 (unless condition 또는 (if condition | (cond (condition1 instructions) | (case expression | (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 | (cond (condition1 instructions) | (case expression | (if condition valueIfTrue valueIfFalse) |
파스칼 | if condition then begin [c] | if condition then begin [c] | case variable of [c] | |
비주얼 베이직 | If condition Then 한 줄, 다음과 같은 경우 instructions 이다instruction1 : instruction2 : ... :If condition Then instructions «Else instructions» | If condition Then 한 줄: C-like 언어에 대한 주의: Else 한 줄의 절If 문에는 다른 한 줄을 포함할 수 있습니다.If 진술. | Select« Case» variable | IIf(condition, valueIfTrue, valueIfFalse) |
Visual Basic.그물 | If(condition, valueIfTrue, valueIfFalse) | |||
조조 | ||||
파이썬[a] | if condition : | if condition : | Python 3.10+:match variable: | Python 2.5+:valueIfTrue if condition else valueIfFalse |
S랑 | if (condition) { instructions } «else { instructions }» | if (condition) { instructions } else if (condition) { instructions } ... «else { instructions }» | switch (variable) { case case1: instructions } { case case2: instructions } ... | |
포트란 | IF (condition) THEN | IF (condition) THEN | SELECT CASE(variable) | |
넷째 | condition IF instructions « ELSE instructions» THEN | condition IF instructions ELSE condition IF instructions THEN THEN | value CASE | 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 [b] | if condition then valueIfTrue else valueIfFalse |
F# | Lightweight 구문 모드: 아래 그림과 같이 한 줄에 또는 들여쓰기가 있는 경우: | Lightweight 구문 모드: 아래 그림과 같이 한 줄에 또는 들여쓰기가 있는 경우: if condition then 상세 구문 모드: 표준 ML과 동일합니다. | ||
표준 ML | if condition then «(»instructions «)» | if condition then «(»instructions «)» | case value of [b] | |
하스켈(GHC) | if condition then expression else expression 또는 when condition (do instructions) 또는 unless notcondition (do instructions) | result condition = expression | case value of { [b] | |
배쉬 셸 | if condition-command; then | if condition-command; then | case "$variable" in | |
커피 스크립트 | if condition then expression «else expression» 또는 if condition 또는 expression if condition 또는 unless condition 또는 expression unless condition | if condition then expression else if condition then expression «else expression» 또는 if condition 또는 unless condition | switch expression 또는 switch expression | 모든 조건은 표현식입니다. |
코볼 | IF condition «THEN» [d] | EVALUATE expression «ALSO expression...» | ||
녹 | if condition { | if condition { | match variable { [b][e] | 모든 조건은 식입니다. |
한다면 | 그렇지 않으면 | 엄선된 케이스 | 조건식 |
- ^a 단일 명령어는 콜론 뒤에 이어지는 동일한 행에 쓸 수 있습니다.여러 명령이 새 줄에서 시작하는 블록에 함께 그룹화됩니다( 들여쓰기 필요).조건식 구문이 이 규칙을 따르지 않습니다.
- ^b 이것은 패턴 매칭이며 선택 케이스와 유사하지만 동일하지는 않습니다.일반적으로 대수 데이터 유형을 분해하는 데 사용됩니다.
- ^c Pascal 계열의 언어에서는 세미콜론은 문장에 포함되지 않습니다.이것은 문장 사이의 구분자이며, 종단자가 아닙니다.
- ^d
END-IF
마지막 마침표 대신 사용할 수 있습니다. - ^e Rust에서는 쉼표(
,
매치 암의 말미에 있는 )는 마지막 매치 암 뒤에 또는 식이 블록인 매치 암 후에 생략할 수 있습니다(아마도 빈 매칭브래킷으로 끝납니다).{}
).
Loop 문
while loop | 루프하면서 하다 | 루프용(카운트 제어) | 앞지르다 | |
---|---|---|---|---|
아다[1] | while condition loop | loop | for index in «reverse» [first .. last discrete_type] loop | for item of «reverse» iterator loop 또는 (for [all some] [in of] [first .. last discrete_type iterator] => predicate) [b] |
알골 68 | «for index» «from first» «by increment» «to last» «while condition» do statements od | for key «to upb list» do «typename val=list[key];» statements od | ||
«while condition» | «while statements; condition» | «for index» «from first» «by increment» «to last» do statements od | ||
APL | :While condition | :Repeat | :For var«s» :In list | :For var«s» :InEach list |
C(C99) | instructions 는 다음 형식의 단일 문 또는 블록일 수 있습니다.{ statements } while (condition) instructions | do instructions while (condition); | for («type» i = first; i <= last; i++) instructions | — |
목표-C | for (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 | |||
자바스크립트 | for (var i = first; i <= last; i++) instructions | EcmaScript 2015 [11]이후:
| ||
PHP | foreach (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 PowerShell | for ($i = first; $i -le last; $i++) instructions | foreach (item in set) instructions | ||
D | foreach (i; first ... last) instructions | foreach («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:repeat { instructions } while condition 1.x: 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 또는 until notcondition | begin 또는 begin | for i in first..last 또는 for i in first...last+1 또는 first.upto(last) { i instructions } | for item in set 또는 set.each { item instructions } |
배쉬 셸 | while condition ;do 또는 until notcondition ;do | — | for ((i = first; i <= last; ++i)) ; do | for item in set ;do |
스칼라 | 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 doWhile: | first to: last do: | collection do: |
일반적인 리스프 | (loop 또는 (do () (notcondition) | (loop | (loop 또는 (dotimes (i N) 또는 (do ((i first (1+ i))) ((>=i last)) | (loop 또는 (loop 또는 (dolist (item list) 또는 (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 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) |
파스칼 | while condition do begin | repeat | for i := first «step 1» to last do begin [a] | for item in set do instructions |
비주얼 베이직 | Do While condition 또는 Do Until notcondition 또는 While condition (Visual Basic).인터넷 사용End While 대신) | Do 또는 Do | i 사전에 신고해야 합니다.
| For Each item In set |
Visual Basic.그물 | For i« As type» = first To last« Step 1» [a] | For Each item« As type» In set | ||
조조 | While condition | Do Until notcondition 또는 Do | ||
파이썬 | while condition : | — | Python 3.x:for i in range(first, last+1): Python 2.x: for i in xrange(first, last+1): | for item in set: |
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) | DO | DO I = first,last | — |
넷째 | BEGIN «instructions» condition WHILE instructions REPEAT | BEGIN instructions condition UNTIL | limit start DO instructions LOOP | — |
OCaml | while condition do instructions done | — | for i = first to last do instructions done | Array.iter (fun item -> instructions) array 또는 List.iter (fun item -> instructions) list |
F# | while condition do | — | for i = first to last do | foritem in set do 또는 Seq.iter (fun item -> instructions) set |
표준 ML | while condition do ( instructions ) | — | Array.app (fn item => instructions) array 또는 app (fn item => instructions) list | |
하스켈(GHC) | — | Control.Monad.forM_ [first..last] (\i -> do instructions) | Control.Monad.forM_list (\item -> do instructions) | |
에펠 | from | |||
커피 스크립트 | while condition 또는 expression while condition 또는 while condition then expression 또는 until condition 또는 expression until condition 또는 until expression then condition | — | for i in [first..last] 또는 for i in [first..last] then expression 또는 expression for i in [first..last] | for item in set 또는 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 | PERFORM procedure-1 «THROUGH procedure-2» «WITH» TEST AFTER UNTIL condition [c]또는 PERFORM «WITH» TEST AFTER UNTIL condition | PERFORM procedure-1 «THROUGH procedure-2» VARYING i FROM first BY increment UNTIL i > last [d]또는 PERFORM VARYING i FROM first BY increment UNTIL i > last [d] | — |
녹 | while condition { | loop { | for i in first..last+1 { 또는 for i in first..=last { | for item in set { [e]또는 set.into_iter().for_each( item expression); [e] |
- ^a "
step
n"은 루프 간격을 변경하는 데 사용됩니다.만약 "step
"는 생략하고 루프 간격은 1입니다. - ^b 이 명령어는 유니버설 수량화('모두' 또는 와 기존 수량화('존재' 또는 를 구현합니다.
- ^c
THRU
대신 사용해도 좋다THROUGH
. - ^d
«IS» GREATER «THAN»
대신 사용해도 좋다>
. - ^e 집합 식 유형은 특성을 구현해야 합니다.
std::iter::IntoIterator
.
예외
던지다 | 핸들러 | 주장. | |
---|---|---|---|
아다[1] | raise exception_name «with string_expression» | begin [b] | pragma Assert («Check =>» boolean_expression ««Message =>» string_expression») |
APL | «string_expression» ⎕SIGNAL number_expression | :Trap number«s»_expression | «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 { instructions }» | System.Diagnostics.Debug.Assert(condition); 또는 System.Diagnostics.Trace.Assert(condition); | |
자바 | try { instructions } catch (exception) { instructions } ... «finally { instructions }» | assert condition «: description»; | |
자바스크립트 | try { instructions } catch (exception) { instructions} «finally { instructions }» | ? | |
D | try { instructions } catch (exception) { instructions } ... «finally { instructions }» | assert(condition); | |
PHP | try { instructions } catch (exception) { instructions } ... «finally { instructions }» | assert(condition); | |
S랑 | try { instructions } catch «exception» { instructions } ... «finally { instructions }» | ? | |
Windows PowerShell | trap «[exception]» { instructions } ... instructions 또는 try { instructions } catch «[exception]» { instructions } ... «finally { instructions }» | [Debug]::Assert(condition) | |
목표-C | @throw exception; | @try { instructions } @catch (exception) { instructions } ... «@finally { instructions }» | NSAssert(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 exception | begin | |
스몰토크 | exception raise | instructionBlock on: exception do: handlerBlock | assert: conditionBlock |
일반적인 리스프 | (error "exception") 또는 (error 또는 (error (make-condition | (handler-case 또는 (handler-bind [a] | (assert condition) 또는 (assert condition 또는 (check-type var type) |
스킴(RRS6) | (raise exception) | (guard (con (condition instructions) ...) instructions) | ? |
ISLISP | (error "error-string" objects) 또는 (signal-condition condition continuable) | (with-handler | ? |
파스칼 | raise Exception.Create() | try Except on E: exception do begin instructions end; end; | ? |
비주얼 베이직 | Err.Raise ERRORNUMBER | With New Try: On Error Resume Next '*** 수업 시작*** 사적인 mstr 설명 ~하듯이 스트링 사적인 mlng ~하듯이 긴 일반의 후보선수 또 만나() mstr 설명 = 에러.묘사 mlng = 에러.번호 끝. 후보선수 일반의 소유물 얻다 번호() ~하듯이 긴 번호 = mlng 끝. 소유물 일반의 소유물 얻다 묘사() ~하듯이 스트링 묘사 = mstr 설명 끝. 소유물 | Debug.Assert condition |
Visual Basic.그물 | Throw exception 또는 Error errorcode | Try | System.Diagnostics. Debug.Assert(condition) 또는 System.Diagnostics.Trace.Assert(condition) |
조조 | Raise exception | Try | — |
파이썬 | raise exception | try: | assert condition |
포트란 | — | ||
넷째 | code THROW | xt CATCH ( code or 0 ) | — |
OCaml | raise exception | try expression with pattern -> expression ... | assert condition |
F# | try expression with pattern -> expression ... 또는 try expression finally expression | ||
표준 ML | raise exception «arg» | expression handle pattern => expression ... | |
하스켈(GHC) | throw exception 또는 throwError expression | catch tryExpression catchExpression 또는 catchError tryExpression catchExpression | assert condition expression |
코볼 | RAISE «EXCEPTION» exception | USE «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) |
- ^공통 리스프에서는
with-simple-restart
,restart-case
그리고.restart-bind
에서 사용할 재시작을 정의합니다.invoke-restart
. 처리되지 않은 상태에서는 스택을 분리하기 전에 구현에서 사용자에게 재시작 메뉴가 표시될 수 있습니다. - ^b 캐치되지 않은 예외는 동적으로 둘러싸인 가장 안쪽 실행으로 전파됩니다.예외는 태스크 간에 전파되지 않습니다(이러한 태스크가 현재 랑데부 내에서 동기화되지 않은 경우).
기타 제어 흐름문
출구 블록(브레이크) | 계속하다. | 라벨. | 브랜치(goto) | 제너레이터로부터의 반환값 | |
---|---|---|---|---|---|
아다[1] | exit «loop_name» «when condition» | — | label: | goto label | — |
알골 68 | value exit; ... | do statements; skip exit; label: statements od | label: ... | go to label; ... | yield(value) |
APL | :Leave | :Continue | label: | →label 또는 :GoTo label | — |
C(C99) | break; | continue; | label: | goto label; | — |
목표-C | |||||
C++(STL) | |||||
D | |||||
C# | yield return value; | ||||
자바 | break «label»; | continue «label»; | — | ||
자바스크립트 | yield value«;» | ||||
PHP | break «levels»; | continue «levels»; | goto label; | yield «key =>» value; | |
펄 | last «label»; | next «label»; | |||
라쿠 | |||||
가세요 | break «label» | continue «label» | goto label | ||
재빠르다 | break «label» | continue «label» | — | ||
배쉬 셸 | break «levels» | continue «levels» | — | — | — |
일반적인 리스프 | (return) 또는 (return-from block) 또는 (loop-finish) | (tagbody tag | (go tag) | ||
스킴 | |||||
ISLISP | (return-from block) | (tagbody tag | (go tag) | ||
Pascal (ISO) | — | label: [a] | goto label; | — | |
Pascal (FPC) | break; | continue; | |||
비주얼 베이직 | Exit block 또는 메서드의 경우,Return | — | label: | GoTo label | |
조조 | Continue block | ||||
Visual Basic.그물 | Yield value | ||||
파이썬 | break | continue | — | yield value | |
RPG IV | LEAVE; | ITER; | |||
S랑 | break; | continue; | |||
포트란 | EXIT | CYCLE | label [b] | GOTO label | — |
루비 | break | next | |||
Windows PowerShell | break «label» | continue | |||
OCaml | — | ||||
F# | |||||
표준 ML | |||||
하스켈(GHC) | |||||
코볼 | EXIT PERFORM 또는EXIT PARAGRAPH 또는EXIT SECTION 또는EXIT. | EXIT PERFORM CYCLE | label «SECTION». | GO TO label | — |
기능들
문자열에 의한 호출 및 함수 선언에 대해서는 리플렉션 참조.
함수 호출 | 기본/기능 | 가치 조정 함수 | 필수 주요 기능 | |
---|---|---|---|---|
아다[1] | foo «(parameters)» | procedure foo «(parameters)» is begin statements end foo | function foo «(parameters)» return type is begin statements end foo | — |
알골 68 | foo «(parameters)»; | proc foo = «(parameters)» void: ( instructions ); | proc foo = «(parameters)» rettype: ( instructions ...; retvalue ); | — |
APL | «parameters» foo parameters | foo←{ statements } | foo←{ statements } | — |
C(C99) | foo(«parameters») | void foo(«parameters») { instructions } | type foo(«parameters») { instructions ... return value; } | «global declarations» |
목표-C | ||||
C++(STL) | ||||
자바 | public static void main(String[] args) { instructions } 또는 public static void main(String... args) { instructions } | |||
D | int main(«char[][] args») { instructions} 또는 int main(«string[] args») { instructions} 또는 void main(«char[][] args») { instructions} 또는 void main(«string[] args») { instructions} | |||
C# | 위와 같음. 또는 하나의 문장만 있는 경우:
| 위와 같음. 또는 식이 될 정도로 간단한 경우:
| static void Main(«string[] args») method_body 대신 돌아올 수 있습니다. int .(C# 7.1부터 시작): 반환될 수 있음 Task 또는Task<int> 만약 그렇다면,async . | |
자바스크립트 | function 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») 또는 (setf (symbol-function 'symbol) | (defun foo («parameters») | — |
스킴 | (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») | (defun foo («parameters») | ||
파스칼 | foo«(parameters)» | procedure foo«(parameters)»; «forward;»[a] | function foo«(parameters)»: type; «forward;»[a] | program name; |
비주얼 베이직 | Foo(«parameters») | Sub Foo«(parameters)» | Function Foo«(parameters)»« As type» | Sub Main() |
Visual Basic.그물 | 위와 같음, 또는 다음 중 하나:
| Sub Main(««ByVal »args() As String») 또는Function Main(««ByVal »args() As String») As Integer | ||
조조 | ||||
파이썬 | foo(«parameters») | def foo(«parameters»): | def foo(«parameters»): | — |
S랑 | foo(«parameters» «;qualifiers») | define foo («parameters») { instructions } | define foo («parameters») { instructions ... return value; } | public define slsh_main () { instructions } |
포트란 | foo («arguments») [c] | SUBROUTINE sub_foo («arguments») [c] | type FUNCTION foo («arguments») [c] | PROGRAM main |
넷째 | «parameters» FOO | : FOO « stack effect comment: ( before -- ) » | : FOO « stack effect comment: ( before -- after ) » | — |
PHP | foo(«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«(parameters)» | def foo«(parameters)» | def foo«(parameters)» | |
녹 | foo(«parameters») | fn foo(«parameters») { instructions } | fn foo(«parameters») -> type { instructions } | fn main() { instructions } |
스칼라 | foo«(parameters)» | def foo«(parameters)»«: Unit =» { instructions } | def foo«(parameters)»«: type» = { instructions ... «return» value } | def main(args: Array[String]) { instructions } |
Windows PowerShell | foo «parameters» | function foo { instructions }; 또는 function foo { «param(parameters)» instructions } | function foo «(parameters)» { instructions ... return value }; 또는 function foo { «param(parameters)» instructions ... return value } | — |
배쉬 셸 | foo «parameters» | function foo { 또는 foo () { | function foo { 또는 foo () { | |
| ||||
OCaml | foo parameters | let «rec» foo parameters = instructions | let «rec» foo parameters = instructions... return_value | |
F# | [<EntryPoint>] let main args = instructions | |||
표준 ML | fun foo parameters = ( instructions ) | fun foo parameters = ( instructions... return_value ) | ||
하스켈 | foo parameters = do | foo parameters = return_value 또는 foo parameters = do | «main :: IO ()» | |
에펠 | foo («parameters») | foo («parameters») | foo («parameters»): type | [b] |
커피 스크립트 | foo() | foo = -> | foo = -> value | — |
foo parameters | foo = () -> | foo = ( parameters ) -> value | ||
코볼 | CALL "foo" «USING parameters» [d] | «IDENTIFICATION DIVISION.» | «IDENTIFICATION DIVISION.» | — |
«FUNCTION» foo«(«parameters»)» | — |
- ^Pascal에는 "가 필요합니다.
forward;
포워드 선언의 경우. - ^b Eiffel에서는 응용 프로그램의 루트 클래스 및 기능을 지정할 수 있습니다.
- ^c Fortran에서는 함수/서브루틴 파라미터를 인수라고 부릅니다(이후).
PARAMETER
언어 키워드).CALL
서브루틴에는 키워드가 필요합니다. - ^d 사용하는 대신
"foo"
는 같은 값을 포함하는 문자열 변수를 대신 사용할 수 있습니다.
유형 변환
여기서 string은 부호 있는 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)); | |
APL | ⍎string_expression | ⍎string_expression | ⍎string_expression | ⍕integer_expression | ⍕float_expression |
C(C99) | integer = atoi(string); | long = atol(string); | float = atof(string); | sprintf(string, "%i", integer); | sprintf(string, "%f", float); |
목표-C | integer = [string intValue]; | long = [string longLongValue]; | float = [string doubleValue]; | string = [NSString stringWithFormat | string = [NSString stringWithFormat |
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 | long = long.Parse | float = float.Parse double = double.Parse | string = number | |
D | integer = std.conv.to!int | long = std.conv.to!long | float = std.conv.to!float double = std.conv.to!double | string = std.conv.to!string | |
자바 | integer = Integer.parseInt | long = Long.parseLong | float = Float.parseFloat double = Double.parseDouble | string = Integer.toString string = String.valueOf | string = Float.toString string = Double.toString |
자바스크립트[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) | long, error = strconv.ParseInt | float, error = strconv.ParseFloat | string = strconv.Itoa(integer) string = strconv.FormatInt string = fmt.Sprint(integer) | string = strconv.FormatFloat string = fmt.Sprint |
녹[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) | string = CStr(number) | |
Visual Basic.그물 (위의 VB 구문을 모두 사용할 수 있습니다).NET 메서드가 올바르게 표시됨) | integer = Integer.Parse | long = Long.Parse | float = Single.Parse double = Double.Parse | string = number | |
조조 | 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) number | WRITE(string,format) number | |||
PHP | integer = 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.toInt | long = string.toLong | float = string.toFloat double = string.toDouble | string = number.toString | |
스몰토크 | integer := Integer readFrom: string | float := Float readFrom: string | string := number asString | ||
Windows PowerShell | integer = [int]string | long = [long]string | float = [float]string | string = [string]number; 또는 string = "number"; 또는 string = (number).ToString() | |
OCaml | let integer = int_ | let float = float_ | let string = string_ | let string = string_ | |
F# | let integer = int string | let integer = int64 string | let float = float string | let string = string number | |
표준 ML | val integer = Int | val float = Real | val string = Int | val string = Real | |
하스켈(GHC) | number = read string | string = show number | |||
코볼 | MOVE «FUNCTION» NUMVAL(string)[c] TO number | MOVE number TO numeric-edited |
- ^a JavaScript는 부동 소수점 숫자만 사용하기 때문에 몇 가지 기술적인 [7]문제가 있습니다.
- ^b Perl에는 별도의 유형이 없습니다.문자열과 숫자는 서로 바꿔 사용할 수 있습니다.
- ^c
NUMVAL-C
또는NUMVAL-F
대신 사용해도 좋다NUMVAL
. - ^는 특성을 구현한 모든 유형을 변환할 수 있습니다.
str::parse
둘다요.str::parse
에러가 없는 경우는, 지정된 타입을 포함한 를 반환합니다.터보피쉬(::<_>
)에 대해서str::parse
유형을 컨텍스트에서 추론할 수 있는 경우 생략할 수 있습니다.
표준 스트림 I/O
에서 읽다. | 에게 편지를 쓰다. | ||
---|---|---|---|
스틴 | 설치하다 | 하드 | |
아다[1] | Get (x) | Put (x) | Put (Standard_Error, x) |
알골 68 | readf(($format$, x)); 또는 getf(stand in, ($format$, x)); | printf(($format$, x)); 또는 putf(stand out, ($format$, x)); | putf(stand error, ($format$, x)); [a] |
APL | x←⎕ | ⎕←x | ⍞←x |
C(C99) | scanf(format, &x); 또는 fscanf(stdin, format, &x); [b] | printf(format, x); 또는 fprintf(stdout, format, x); [c] | fprintf(stderr, format, x); [d] |
목표-C | data = [[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 또는 Console.Error |
D | x = 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 또는 std.stdio |
자바 | 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)println(x) (1.x) | |
자바스크립트 웹 브라우저 구현 | document.write(x) | ||
자바스크립트 활성 서버 페이지 | Response.Write(x) | ||
자바스크립트 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*) 또는 |
스킴(RRS6) | (define x (read-line)) | (display x) 또는 | (display x (current-error-port)) 또는 |
ISLISP | (setf x (read-line)) | | |
파스칼 | read(x); 또는 readln(x); | write(x); 또는 writeln(x); | write(stderr, x); 또는 writeln(stderr, x); |
비주얼 베이직 | Input« prompt,» x | Print x 또는 ? x | — |
Visual Basic.그물 | x = Console.Read() 또는 x = Console.ReadLine() | Console.Write(«format,»x) 또는 Console.WriteLine(«format, »x) | Console.Error 또는 Console.Error |
조조 | x = StandardInputStream.Read() 또는 x = StandardInputStreame.ReadLine() | StandardOutputStream.Write(x) 또는 StandardOutputStream.WriteLine(x) | StdErr.Write(x) 또는 StdErr.WriteLine(x) |
파이썬 2.x | x = raw_input(«prompt») | print x 또는 sys.stdout.write(x) |
또는 sys.stderr.write(x) |
파이썬 3.x | x = input(«prompt») | print(x«, end=""») | print(x«, end=""», file=sys.stderr) |
S랑 | fgets (&x, stdin) | fputs (x, stdout) | fputs (x, stderr) |
포트란 | READ(*,format) variable names 또는 READ(INPUT_UNIT,format) variable names [e] | WRITE(*,format) expressions 또는 WRITE(OUTPUT_UNIT,format) expressions [e] | WRITE(ERROR_UNIT,format) expressions [e] |
넷째 | buffer length ACCEPT ( # chars read ) | buffer length TYPE | — |
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 = gets | puts 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 |
OCaml | let 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 ... |
표준 ML | val str = TextIO.inputLIne TextIO.stdIn | print str | |
하스켈(GHC) | x <- readLn 또는 str <- getLine | print x 또는 putStrLn str | hPrint stderr x 또는 hPutStrLn stderr str |
코볼 | ACCEPT x | DISPLAY x |
- ^a ALGOL 68을 "형식화되지 않은" 전송 루틴으로 추가:
read
,write
,get
,그리고.put
. - ^b
gets(x)
그리고.fgets(x, length, stdin)
stdin에서 포맷되지 않은 텍스트를 읽습니다.gets 사용은 권장되지 않습니다. - ^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_Count | Command_Name |
C(C99) | argv[n] | argc | 첫 번째 의론 |
목표-C | |||
C++ | |||
C# | args[n] | args.Length | Assembly.GetEntryAssembly() |
자바 | args.length | ||
D | 첫 번째 의론 | ||
자바스크립트 Windows 스크립트호스트의 실장 | WScript.Arguments(n) | WScript.Arguments.length | WScript.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 | 첫 번째 의론 |
일반적인 리스프 | ? | ? | ? |
스킴(RRS6) | (list-ref (command-line) n) | (length (command-line)) | 첫 번째 의론 |
ISLISP | — | — | — |
파스칼 | ParamStr(n) | ParamCount | 첫 번째 의론 |
비주얼 베이직 | Command [b] | — | App.Path |
Visual Basic.그물 | CmdArgs(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 | argc = COMMAND_ARGUMENT_COUNT () | CALL GET_COMMAND_ARGUMENT (0,progname) |
PHP | $argv[n] | $argc | 첫 번째 의론 |
배쉬 셸 | $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 |
OCaml | Sys.argv.(n) | Array.length Sys.argv | 첫 번째 의론 |
F# | args.[n] | args.Length | Assembly.GetEntryAssembly() |
표준 ML | List.nth (CommandLine.arguments (), n) | length (CommandLine.arguments ()) | CommandLine.name () |
하스켈(GHC) | do { args <- System.getArgs; return length args !! n } | do { args <- System.getArgs; return length args } | System.getProgName |
코볼 | [c] | — |
- ^a 녹슬면
std::env::args
그리고.std::env::args_os
반복기 반환,std::env::Args
그리고.std::env::ArgsOs
각각 다음과 같다.Args
각 인수를 로 변환합니다.String
UTF-8로 변환할 수 없는 인수에 도달하면 패닉 상태가 됩니다.ArgsOs
운영체제에서 원시 문자열을 손실 없이 나타냅니다( ) 。std::ffi::OsString
UTF-8이 무효일 수 있습니다. - ^b Visual Basic에서는 명령줄 인수는 분리되지 않습니다.이들을 분리하려면 분할 기능이 필요합니다.
Split(string)
. - ^c COBOL 표준은 명령줄 인수에 액세스할 수 있는 수단을 포함하지 않지만, 이러한 인수에 액세스하기 위한 일반적인 컴파일러 확장 기능에는 메인 프로그램의 파라미터 정의 또는 사용이 포함됩니다.
ACCEPT
진술들.
명령어 실행
셸 명령어 | 프로그램 실행 | 현재 프로그램을 새로 실행한 프로그램으로 바꾸기 | |
---|---|---|---|
아다[1] | 언어 표준의 일부가 아닙니다.일반적으로 컴파일러가 제공하는 패키지에 의해 또는 C 또는 [16]POSIX에 인터페이스하여 수행됩니다. | ||
C | system("command"); | execl(path, args); 또는 execv(path, arglist); | |
C++ | |||
목표-C | [NSTask launchedTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)arguments]; | ||
C# | System.Diagnostics | ||
F# | |||
가세요 | exec.Run(path, argv, envv, dir, exec.DevNull, exec.DevNull, exec.DevNull) | os.Exec(path, argv, envv) | |
비주얼 베이직 | Interaction.Shell(command «, WindowStyle» «, isWaitOnReturn») | ||
Visual Basic.그물 | Microsoft.VisualBasic | System.Diagnostics | |
조조 | Shell.Execute(command «, Parameters») | FolderItem.Launch(parameters, activate) | — |
D | std.process.system("command"); | std.process.execv(path, arglist); | |
자바 | Runtime.exec(command); 또는 new ProcessBuilder(command).start(); | ||
자바스크립트 Windows 스크립트호스트의 실장 | | WshShell.Exec(command) | |
일반적인 리스프 | (uiop:run-program command) | ||
스킴 | (system command) | ||
ISLISP | — | — | — |
파스칼 | 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 또는 Unix.execve prog args env |
표준 ML | OS.Process.system command | Unix.execute (path, args) | Posix.Process.exec (path, args) |
하스켈(GHC) | System.system command | System.Process | Posix.Process |
펄 | system(command) 또는 $output = `command` 또는 $output = qx(command) | exec(path, args) | |
루비 | system(command) 또는 output = `command` | exec(path, args) | |
PHP | system(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») [a] | ||
Windows PowerShell | [Diagnostics.Process]::Start(command) | «Invoke-Item »program arg1 arg2 ... | |
배쉬 셸 | output=`command` 또는 output=$(command) | program arg1 arg2 ... |
레퍼런스
- ^ a b c d e f g h i j k l m n o p Ada 레퍼런스 매뉴얼– 언어 및 표준 라이브러리, ISO/IEC 8652:201x (E),"Reference Manual" (PDF). Archived from the original (PDF) on 2011-04-27. Retrieved 2013-07-19.
- ^ "Common Lisp HyperSpec (TM)". lispworks.com. Retrieved 30 January 2017.
- ^ "www.islisp.info: Specification". islisp.info. Archived from the original on 22 January 2016. Retrieved 30 January 2017.
- ^ a b "selected_int_kind in Fortran Wiki". fortranwiki.org. Retrieved 30 January 2017.
- ^ "Erlang — Types and Function Specifications". erlang.org. Retrieved 30 January 2017.
- ^ "Erlang — Advanced". erlang.org. Retrieved 30 January 2017.
- ^ a b 8.5 번호 타입
- ^ a b "selected_real_kind in Fortran Wiki". fortranwiki.org. Retrieved 30 January 2017.
- ^ "The GNU C Library: Complex Numbers". gnu.org. Retrieved 30 January 2017.
- ^ "Grammar vb". Visual Basic Language Specification. 2016-06-17. Archived from the original on 2019-08-29. Retrieved 2019-08-29.
- ^ "for...of". mozilla.org. Retrieved 30 January 2017.
- ^ "Try-Catch for VB". google.com. Retrieved 30 January 2017.
- ^ Klabnik, Steve; Nichols, Carol. "Error Handling". The Rust Programming Language.
- ^ "Prime decomposition – Rosetta Code". rosettacode.org. Retrieved 30 January 2017.
- ^ "iso_fortran_env in Fortran Wiki". fortranwiki.org. Retrieved 30 January 2017.
- ^ "Execute a system command – Rosetta Code". rosettacode.org. Retrieved 30 January 2017.
- ^ "EXECUTE_COMMAND_LINE – The GNU Fortran Compiler". gnu.org. Retrieved 30 January 2017.