[질문] golang에는 Python의 decorator , list-comprehension 같은 기능이 있나요?

130 views
Skip to first unread message

zestizer

unread,
Aug 30, 2012, 11:50:58 PM8/30/12
to golang...@googlegroups.com
안녕하세요 요즘 golang에 관심이 많아서, 공부하고 있는 학생입니다.

python의 decorator와 비슷한 기능을 하는 기능이 golang에 있는지 궁금합니다. 

가령 python에서는 

def entryExit(f):
    def new_f():
        print "Entering", f.__name__
        f()
        print "Exited", f.__name__
    return new_f

@entryExit
def func1():
    print "inside func1()"

@entryExit
def func2():
    print "inside func2()"

func1()
func2()
print func1.__name__

같은 방식으로 사용할수 있다고 알고 있는데요. 

golang에서는 python/decorator,java/annotation 같은 기능이 있는지 궁금하네요. (혹시 없으면, 다른 더 좋은 방법이 있어서 그런건지, 혹은 decorator,annotation같은 방식이 문제가 있는 건지 궁금하긴 합니다.)

golang에서는 function을 curry할수 있을까요?  http://en.wikipedia.org/wiki/Curry_(programming_language)

혹시 golang에는 python PEP같은 언어 디자인 제안 문서가 따로 존재하나요? http://www.python.org/dev/peps/

----

읽어 주셔서 감사합니다.



Leonardo YongUk Kim

unread,
Aug 31, 2012, 5:26:20 AM8/31/12
to golang...@googlegroups.com
LC를 지원할 생각은 없는 것 같습니다.

"I thought I would miss list comprehensions a lot, but I find that
their absence results in cleaner code that is easier to understand
even when compared to relatively simple list comprehensions [in
Python]." -- Thirsteh

http://go-lang.cat-v.org/quotes

see also: https://groups.google.com/forum/?fromgroups=#!msg/golang-nuts/cC8sx5MUYDc/PeTuczpc1ZIJ

대신에 Map을 사용하는 예제 코드는 본 적이 있습니다. Map, Filter가 사실상 LC와 동등한 표현력을 가졌기 떄문에
아쉽다면 Map이나 Filter를 쓰시는 것도 한 방법인 것 같습니다.

또 파이썬의 데코레이터는 순수한 신택스 슈가인데요. 거기에 딱 맞는 GO언어 피쳐는 없는 것 같습니다.

GO언어는 메일링 리스트와 챗을 통해서 언어를 개선해 나가는데 현재의 상태에서 PEP같은 작업을 하기에는 문서 작업의 부담이 큰 것 같습니다.


Regards,
Leonardo YongUk KIM


2012/8/31 zestizer <zest...@gmail.com>:

> --
> --
> * 이 그룹에 이메일로 게시하려면 다음 주소로 이메일을 보내시면 됩니다.
> golang...@googlegroups.com
> * 추가 옵션을 보려면 http://groups.google.com/group/golang-korea?hl=ko?hl=ko의 그룹을
> 방문하세요.
>
>

Jaehyun Yeom

unread,
Sep 4, 2012, 4:53:12 PM9/4/12
to golang...@googlegroups.com
map이나 filter 함수가 기본 제공되지는 않죠?

2012/8/31 Leonardo YongUk Kim <dali...@gmail.com>
Reply all
Reply to author
Forward
0 new messages