User loginNavigation |
Unstructured casting considered harmful to securityUnstructured casting (e.g. Java, C#, C++, etc.) can be harmful to security. Structured casting consists of the following: 1: Casting self to an interface implemented by this Actor 2: Upcasting a) an Actor of an implementation type to the interface type of the implementation b) an Actor of an interface type to the interface type that was extended 3: Conditional downcasting of an Actor of an interface type to an extension interface type. (An implementation type cannot be downcast because there is nothing to which to downcast.) Claim: All other casting is unstructured and should be prohibited. Edit: The above was clarified as a result of a perceptive FriAM comment by Marc Stiegler
Actor DepositOnlyAccount[initialBalance:Euro] uses SimpleAccount[initialBalance]。
implements Account using
deposit[anAmount] →
⍠Account⨀SimpleAccount.deposit[anAmount]¶
// use deposit message handler from SimpleAccount (see below)
getBalance[ ] → ⦻¶ // always throw exception
withdraw[anAmount:Euro] → ⦻§▮ // always throw exception
As a result of the above definition, DepositOnlyAccount⊒Account and
getBalance[ ] ↦ ⦻, // always throws exception
withdraw[ ] ↦ ⦻, // always throws exception
deposit[Euro] ↦ Void▮
The above makes use of the following:
Interface Account with
getBalance[ ]↦Euro,
deposit[Euro]↦Void,
withdraw[Euro]↦Void▮
Actor SimpleAccount[startingBalance:Euro]
myBalance ≔ startingBalance。
// myBalance is an assignable variable
// initialized with startingBalance
implements Account using
getBalance[ ] → myBalance¶
deposit[anAmount] →
Void // return Void
afterward myBalance ≔ myBalance+anAmount¶
// the next message is processed with
// myBalance reflecting the deposit
withdraw[anAmount:Euro]:Void →
(amount > myBalance) �
True ⦂ Throw Overdrawn[ ] ⍌
False ⦂ Void // return Void
afterward myBalance ≔ myBalance–anAmount ⍰§▮
// the next message is processed with updated myBalance
By Hewitt at 2015-08-22 18:32 | LtU Forum | previous forum topic | next forum topic | other blogs | 4463 reads
|
Browse archives
Active forum topics |
Recent comments
8 hours 41 min ago
1 day 5 hours ago
2 days 10 hours ago
2 days 10 hours ago
1 week 11 hours ago
1 week 11 hours ago
1 week 11 hours ago
4 weeks 1 day ago
4 weeks 6 days ago
4 weeks 6 days ago