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 | 4212 reads
|
Browse archives
Active forum topics |
Recent comments
16 weeks 4 days ago
16 weeks 4 days ago
16 weeks 4 days ago
38 weeks 5 days ago
43 weeks 12 hours ago
44 weeks 4 days ago
44 weeks 4 days ago
47 weeks 2 days ago
51 weeks 6 days ago
52 weeks 18 sec ago