tailieunhanh - Concepts, Techniques, and Models of Computer Programming - Chapter 3
Declarative Programming Techniques Hãy xem xét bất kỳ hoạt động tính toán, tức là, một đoạn chương trình với các đầu vào và đầu ra. Chúng tôi cho rằng hoạt động được nếu khai báo bất cứ khi nào được gọi là với các đối số tương tự, nó sẽ trả về cùng một kết quả độc lập của bất kỳ nhà nước tính toán khác | Chapter 3 Declarative Programming Techniques S il vous plait. dessine-moi un arbre If you please - draw me a tree - Freely adapted from Le Petit Prince Antoine de Saint-Exupery 1900-1944 The nice thing about declarative programming is that you can write a specification and run it as a program. The nasty thing about declarative programming is that some clear specifications make incredibly bad programs. The hope of declarative programming is that you can move from a specification to a reasonable program without leaving the language. - The Craft of Prolog Richard O Keefe - Consider any computational operation . a program fragment with inputs and outputs. We say the operation is declarative if whenever called with the same arguments it returns the same results independent of any other computation state. Figure illustrates the concept. A declarative operation is independent does not depend on any execution state outside of itself stateless1 has no internal execution state that is remembered between calls and deterministic always gives the same results when given the same arguments . We will show that all programs written using the computation model of the last chapter are declarative. Why declarative programming is important Declarative programming is important because of two properties Declarative programs are compositional. A declarative program consists of components that can each be written tested and proved correct 1The concept of stateless is sometimes called immutable . Copyright 2001-3 by P. Van Roy and S. Haridi. All rights reserved. 114 Declarative Programming Techniques Figure A declarative operation inside a general computation independently of other components and of its own past history previous calls . Reasoning about declarative programs is simple. Programs written in the declarative model are easier to reason about than programs written in more expressive models. Since declarative programs compute only values simple algebraic and logical .
đang nạp các trang xem trước