2013-06-04 8 views

答えて

6

宣言形式は、プログラムの意図/最終結果をどのように到着させるべきかを宣言するものです。基本的には、設定ファイルとコードの区別です。比較:

(のpython-擬似コード)のようなもの対
CC=gcc 
CFLAGS=-I. 
DEPS = hellomake.h 

%.o: %.c $(DEPS) 
    $(CC) -c -o [email protected] $< $(CFLAGS) 

hellomake: hellomake.o hellofunc.o 
    gcc -o hellomake hellomake.o hellofunc.o -I. 

:フォーマットはうまく設計されている場合

CC = "gcc" 
CFLAGS = "-I." 
DEPS = ["hellomake.h"] 
def make_o_file(o_file, deps): 
    #don't recompile if it exists & is current 
    c_file = "%s.c" % os.path.splitext(o_file)[0] 
    if (os.path.exists(o_file) 
      and is_newer(o_file, c_file) 
      and all(is_newer(o_file, dep) for dep in deps)): 
     return 

    #else actually compile it 
    compile_c_file(CC, code_file, o_file, CFLAGS) 

if target == "hellomake": 
    make_o_file("hellomake.o", DEPS) 
    make_o_file("hellofunc.o", DEPS) 
    link_o_files("hellomake", ["hellomake.o", "hellofunc.o"]) 

前者は処理するために、人間のためにはるかに容易にすることができます。 declarative programmingのWikipediaが役に立つかもしれません。

関連する問題