Code Metaphor

Programming, Writing, Reading, Thoughts…

Phunctional Lambda: 이제 고차 함수 된다

예전 글에서 고차 함수를 사용할 수 없다고 했었는데, 이제 잘 된다.

$g = 1;

$outer = def($a)?
    def($b)? $g + $a + $b :fed()
:fed();

var_dump($outer->call(10)->call(100));

위 코드는 int(111)을 출력한다.

에러 라인도 제대로 짚어준다.

var_dump($outer->call(10)->call());

위와 같이 시그너쳐에 맞지 않는 호출을 했을 경우,

Warning: Missing argument 1 for Lambda functor,
  called in file.php on line 7 and instantiated in file.php on line 4
  in Phunctional/Lambda.php on line 334

클로져 안쪽에서 생성된 함수라도 해당 라인을 정확히 짚어준다. (마지막 in Phunctional/Lambda.php on line 334 메세지는 trigger_error() 함수를 이용했을 때 어쩔 수 없이 껴버리는 부분으로, 제거할 수 없었다.)

This entry was posted on September 21, 2007 at 4:44 PM. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

One Response to “Phunctional Lambda: 이제 고차 함수 된다”

  1. Heungsub Says:

    섹시한데요!

Powered by WordPress. Styled by Hong, MinHee. XML Feed, Comments XML Feed.