상위 질문
타임라인
채팅
관점

님 (프로그래밍 언어)

정적 자료형, 컴파일 시스템 프로그래밍 언어 위키백과, 무료 백과사전

님 (프로그래밍 언어)
Remove ads

(Nim)은 범용 목적다중 패러다임정적 자료형, 컴파일 시스템 프로그래밍 언어이다.[9] Andreas Rumpf 등이 소속된 팀이 설계하고 개발했다. 님은 컴파일 타임 코드 생성, 대수적 자료형, C, C++, 오브젝티브-C, 자바스크립트 등과 연계되는 외부 함수 인터페이스(FFI), 또 해당 언어들로의 컴파일 지원을 제공함으로써 메타프로그래밍, 함수, 메시지 전달, 절차, 객체 지향 프로그래밍 스타일을 지원하는 등 효율적이고 표현적이며 우아한 방식을 제공하도록 설계되었다.

간략 정보 패러다임, 설계자 ...
Remove ads

문법 예시

# Let's declare a function that takes any type of number and displays its double
# In Nim functions with side effect are called "proc"
proc timesTwo(i: SomeNumber) =
  echo i * 2


# Let's write another function that takes any ordinal type, and returns
# the double of the input in its original type, if it is a number;
# or returns the input itself otherwise.
# We use a generic Type(T), and precise that it can only be an Ordinal
func twice_if_is_number[T: SomeOrdinal](i: T): T =
  when T is SomeNumber: # A `when` is an `if` evaluated during compile time
    result = i * 2 # You can also write `return i * 2`
  else:
    # If the Ordinal is not a number it is converted to int,
    # multiplied by two, and reconverted to its based type
    result = (i.int * 2).T

echo twice_if_is_number(67) # Passes an int to the function
echo twice_if_is_number(67u8) # Passes an uint8
echo twice_if_is_number(true) # Passes a bool (Which is also an Ordinal)
Remove ads

같이 보기

각주

외부 링크

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads