Content deleted Content added
noting Image:Mercury logo.jpg is about to be deleted WP:NONFREE |
|||
Line 22:
[[User:BetacommandBot|BetacommandBot]] ([[User talk:BetacommandBot|talk]]) 14:43, 8 March 2008 (UTC)
== Examples of difficulties introduced by declarativeness? ==
"can make certain programming constructs (such as a switch over a number of options, with a default) harder to express"
Prolog:
(
Day = saturday, !, OpenHours = (8 - 15)
;
Day = sunday, !, OpenHours = (9 - 13)
;
OpenHours = (8 - 17)
)
Mercury: For the same amount of compiler checking as the above, one could use an if-then-else structure:
( if Day = saturday then
OpenHours = (8 - 15)
else if Day = sunday then
OpenHours = (9 - 13)
else
OpenHours = (8 - 17)
).
[Actually, for the above simple example one would probably use the functional form of if-then-else, i.e. OpenHours = ( if ... then (8 - 15) else if ... then (9 - 13) else (8 - 17) ).]
The above doesn't seem a good example of extra difficulty. I'm sure there better examples (maybe failure-driven I/O ?); can someone supply one?
|