BCPL
BCPL(Basic Combined Programming Language)은 1966년 케임브리지 대학교에서 마틴 리처드가 설계한 절차적 명령형, 구조적 컴퓨터 프로그래밍 언어이다.
원래 다른 언어들을 위한 컴파일러를 작성하기 위해 고안하였다가, BCPL은 더 이상 일반적으로 쓰이지 않게 되었다. 그러나 이 언어의 영향력은 여전한데 BCPL을 문법적으로 변경한 것이 이른바 B이고, C 프로그래밍 언어가 이것 위에 기반을 두었기 때문이다. 이로 말미암아 수많은 C 프로그래머들에게 Before C Programming Language라는 유머러스한 배크로님을 선사해 주었다.[1]
BCPL은 활 괄호({ })를 사용한 최초의 프로그래밍 언어이다. 괄호는 거듭되는 문법의 변화를 생존시켰고, 프로그램 소스 코드의 문들을 표기하는 일반적인 수단이 되었다. 현실적으로 당시 키보드의 제한으로 소스 프로그램들은 종종 { } 기호 대신 $( 와 $) 기호를 종종 사용하였다. BCPL에서 쓰이는 '//'라는 한 줄 주석은 C에 도입되지 않았지만 C++과 나중에 C99에 다시 등장하였다.
예
아래의 완전하고 호환성 있는 예제는 마틴 리처드의 BCPL 배포판에서 가져온 것이다.
팩토리얼 인쇄:
GET "LIBHDR"
LET START() = VALOF $(
FOR I = 1 TO 5 DO
WRITEF("%N! = %I4*N", I, FACT(I))
RESULTIS 0
$)
AND FACT(N) = N = 0 -> 1, N * FACT(N - 1)
N퀸 문제의 카운트 해결책:
GET "LIBHDR"
GLOBAL $(
COUNT: 200
ALL: 201
$)
LET TRY(LD, ROW, RD) BE
TEST ROW = ALL THEN
COUNT := COUNT + 1
ELSE $(
LET POSS = ALL & ~(LD | ROW | RD)
UNTIL POSS = 0 DO $(
LET P = POSS & -POSS
POSS := POSS - P
TRY(LD + P << 1, ROW + P, RD + P >> 1)
$)
$)
LET START() = VALOF $(
ALL := 1
FOR I = 1 TO 12 DO $(
COUNT := 0
TRY(0, 0, 0)
WRITEF("%I2-QUEENS PROBLEM HAS %I5 SOLUTIONS*N", I, COUNT)
ALL := 2 * ALL + 1
$)
RESULTIS 0
$)
각주
- ↑ Expert C Programming: Deep C Secrets by Peter Van Der Linden (Prentice Hall, 1994)
| 이 글은 프로그래밍 언어에 관한 토막글입니다. 여러분의 지식으로 알차게 문서를 완성해 갑시다. |
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.