Concatenative Programming Language
´ëÃæ ¾îµðÂëÀÇ À§»ó ¶ApplicativeProgrammingLanguage? ConcatenativeProgrammingLanguage? ¶
''imperative <-> functionalÀΰÍó·³. imperative¿Í object-oriented°¡ ÇÔ²² ÀÖÀ»¼öÀÖµíÀÌ. ¿¹¸¦µé¾î, haskellÀº functional + applicative°ÚÁÒ. ¶Ç ¸í¹éÈ÷ concatenativeÀÎ FactorLanguageÀÇ °æ¿ì ¸»¾¸ÇϽŠimperative, +object-orientedÀ̱⵵ Çϱ¸¿ä. ±×°ÍµéÀÌ °°Àº ¼öÁ÷¼±»ó¿¡ ÀÖ¾î¼ ¾î¶²ÁöÁ¡ÀÌ µü ÇϳªÀÇ Æз¯´ÙÀÓ¸¸ ¦iÁö´Â ¾Ê´Â´Ù´Â°É Àß ¾Æ½Ã´ÂµíÇѵ¥¿ä? (¾ð±ÞÇϼ̵íÀÌ ÆÄÀ̽ã, ÀÚ¹Ù´Â ÃàÀÌ 2°³ÀÎ °ø°£¿¡ ÀÖ°ÚÁÒ. À§Ä¡´Â imperative, object-oriented. ±×¸®°í ±× 2Â÷¿øÀÇ Ãà¿¡ concatenative, applicativeÀ» Ãß°¡ÇÏ´Â°Ô ¾Æ´Ï¶ó »õ·Î¿î ÃàÀÌ ÀÖ´Ù°í »ý°¢ÇÏ½Ã´Â°Ô ¸ÂÁö¾ÊÀ»±î½Í³×¿ä.)
applicative, concatenative°¡ functional, object-oriented, imperativeµî°ú °°Àº paradigmÀÌÁö¸¸, °°Àº À§»ó¿¡ À§Ä¡ÇÑ°Ô ¾Æ´Ï¶ó°í¹Û¿£ ¼³¸íÀ» ¸øµå¸®°Ú³×¿ä.
http://concatenative.org/wiki/view/Concatenative language <- ¿©±â¸¦ Âü°íÇØÁֽñæ.
- ageldama''
''»çÁ·À» ´õÇغ¸¸é applicative language¿¡¼ x¿¡ ´ëÇؼ ÇÔ¼ö A, B, C, DÀ» Àû¿ëÇÏ´Â ¿¹´Â ´ÙÀ½°ú °°´Ù°í ÇÏ´õ±º¿ä. (D (C (B (A x)))) ȤÀº D(C(B(A(x)))). ÀÌ¿¡ ¹ÝÇؼ concatenative language¿¡¼´Â x A B C D¿Í °°ÀÌ Ç¥ÇöÇÕ´Ï´Ù. (¾Æ¹«¸® »ý°¢Çصµ ÀÚ¹Ù, ÆÄÀ̽ãÀº ÀüÀÚÀÎ°Í °°Àºµ¥¿ä^^;). Á¤È®ÇÑÁö´Â È®½ÅÀÌ ¾øÁö¸¸, unix-shell°ú °°ÀÌ pipeÀ» ÀÌ¿ëÇØ ÇϳªÀÇ ÀÚ·áÈ帧¿¡ ´ëÇؼ ¿©·¯ ¿¬»êÀ» Àû¿ëÇϴ¿¹µµ concatenativeÀÇ ÇÑ¿¹°¡ ¾Æ´Ò±î ½Í½À´Ï´Ù. find /etc -name "*.bak" | sort | uniq | wc -l -ageldama'' "Hello, World!" ¶
! 1) "Hello, World!" ¹®ÀÚ¿À» ½ºÅÿ¡ ³Ö¾î³õ°í
! 2) ½ºÅÿ¡¼ Çϳª¸¦ ²¨³» ȸ鿡 Ãâ·ÂÇÏ´Â print '¿öµå'¸¦ Æò°¡ "Hello, World!" print °£´ÜÇÑ Factor¿¡¼ REPL¼¼¼Ç ¶(ÀÌÇÏÀÇ ( scratchpad )Àº ÇÁ·ÒÇÁÆ®, !À¸·Î ½ÃÀÛÇÏ´Â ÇàÀº ÁÖ¼®.)
! ½ºÅÿ¡ 2¸¦ ³Ö¾î¿ä. ( scratchpad ) 2 --- Data stack: 2 ! ½ºÅÿ¡ 3À» ³Ö¾î¿ä. ( scratchpad ) 3 --- Data stack: 2 3 ! ½ºÅÃÀÇ µÎ°ªÀ» ´õÇؼ °á°ú¸¦ ½ºÅÿ¡ ½×¾Æ¿ä. ( scratchpad ) + --- Data stack: 5 ! ½ºÅÃÀÇ °ªÀÇ Á¦°öÀ» ±¸ÇØ¿ä. ( scratchpad ) sq --- Data stack: 25 ! ½ºÅÃÀÇ ¸Ç ¸¶Áö¸·°ªÀ» ²¨³»¼ º¸¿©Áà¿ä. ( scratchpad ) . 25 ! Áö±Ý±îÁö »ç¿ëÇÑ, +, sq, . ÇÔ¼öÀÇ Á¤ÀǸ¦ »ìÆ캸±â ( scratchpad ) \ + see IN: math MATH: + ( x y -- z ) foldable flushable ( scratchpad ) \ sq see USING: kernel ; IN: math : sq ( x -- y ) dup * ; inline ( scratchpad ) \ . see USING: io ; IN: prettyprint : . ( obj -- ) pprint nl ; ! (2+3)**2À» ±¸Çؼ ȸ鿡 Ãâ·ÂÇØ¿ä. (Áö±Ý±îÁö¸¦ ÇÑÁÙ·Î.) ( scratchpad ) 2 3 + sq . 25
°ü·ÃÁ¤º¸ ¶
|