Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[S02] relax Duration a bit
Durations are now dimensional but not restrictive.  Added some
speculation about how to approach dimensional analysis gradually.
  • Loading branch information
TimToady committed Nov 17, 2010
1 parent 6cd1df9 commit 3104c5b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions S02-bits.pod
Expand Up @@ -13,8 +13,8 @@ Synopsis 2: Bits and Pieces

Created: 10 Aug 2004

Last Modified: 16 Nov 2010
Version: 228
Last Modified: 17 Nov 2010
Version: 229

This document summarizes Apocalypse 2, which covers small-scale
lexical items and typological issues. (These Synopses also contain
Expand Down Expand Up @@ -1355,14 +1355,16 @@ be taken as durations, as above); you may not add two instants.

$instant + $instant # WRONG
$instant - $instant # ok, returns a duration
$instant + $duration # ok, returnas an instant

Durations allow additive operations with other durations, and allow
any numeric operation with a number as the other argument:

$duration * $duration # WRONG, durations aren't geometric
$duration * 2 # ok, a duration twice as long
2 * $duration # same
$instant + $duration # ok, returns an instant

Numeric operations on durations return C<Duration> where that makes
sense (addition, subtraction, modulus). The type returned for other
numeric operations is unspecified; they may return normal numeric
types or they may return other dimensional types that attempt to
assist in dimensional analysis. (The latter approach should likely
require explicit declaration for now, until we can demonstrate that
it does not adversely impact the average programmer, and that it
plays well with the concept of gradual typing.)

The C<Blob> type is like an immutable buffer, and therefore
responds both to array and (some) stringy operations. Note that,
Expand Down

0 comments on commit 3104c5b

Please sign in to comment.