immutable objects ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

immutable objects ?

Martin Rubi
Is there a way to make any object be immutable in Dolphin 5 or Dolphin 6 ?
(I'm mean without using some sort of wrapper)

regards
martin


Reply | Threaded
Open this post in threaded view
|

Re: immutable objects ?

Bruno Brasesco
Martin Rubi escribió:
> Is there a way to make any object be immutable in Dolphin 5 or Dolphin 6 ?
> (I'm mean without using some sort of wrapper)
>
> regards
> martin
>
>

In D6:

anObject isImmutable: true.

If the object has a collection you have to send the message to the
collection too.

Bank
instVar: 'name address accounts'

aBank isImmutable: true.
aBank name: newName. " raise an exception "
aBank addAccount: anAccount "no exception"

addAccount: anAccount

        ^accounts add: anAccount

regards bruno


Reply | Threaded
Open this post in threaded view
|

Re: immutable objects ?

Martin Rubi
Bruno, many thanks.
I guess I should upgrade to D6 then :)

best regards

"Bruno" <[hidden email]> escribió en el mensaje
news:[hidden email]...
> Martin Rubi escribió:
> > Is there a way to make any object be immutable in Dolphin 5 or Dolphin 6
?

> > (I'm mean without using some sort of wrapper)
> >
> > regards
> > martin
> >
> >
>
> In D6:
>
> anObject isImmutable: true.
>
> If the object has a collection you have to send the message to the
> collection too.
>
> Bank
> instVar: 'name address accounts'
>
> aBank isImmutable: true.
> aBank name: newName. " raise an exception "
> aBank addAccount: anAccount "no exception"
>
> addAccount: anAccount
>
> ^accounts add: anAccount
>
> regards bruno


Reply | Threaded
Open this post in threaded view
|

Re: immutable objects ?

Andy Bower-3
Martin,

> Bruno, many thanks.
> I guess I should upgrade to D6 then :)

An excellent idea!

Best regards

--
Andy Bower
Dolphin Support
www.object-arts.com