What is a programming idiom?

后端 未结 10 2049
一向
一向 2020-12-04 06:42

I see the phrase \"programming idiom\" thrown around as if it is commonly understood. Yet, in search results and stackoverflow I see everything...

From micro:

<
10条回答
  •  情歌与酒
    2020-12-04 07:26

    An "idiom" in (non-programming) language is a saying or expression which is unique to a particular language. Generally something which doesn't follow the "rules" of the langauge, and just exist because native speakers "just know" what it means. (for instance, in English we say "in line" but "out of line" -- that would be idiomatic)

    Moving this to the programming arena, we get things like:

     if(c=GetValue())
     {...}
    

    which actaually means:

     c = GetValue();
     if (c != 0)
     {....}
    

    which every C/C++ programmer understand, but would totally baffle someone coming from a different programming language.

提交回复
热议问题