Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 0.6
-
Component/s: Boo.Lang.Useful
-
Labels:None
-
Number of attachments :
Description
It works like the Eiffel "once" keyword. The method decorated with the attribute will only run once. Subsequent calls will return a cached value. It is thread safe (it will only lock the first time it is called).
Example:
[once] def ComputeHash():
return sha1Managed.ComputeHash(someBytes)
The hash will only be computer once.
It is not recommended that one uses this attribute
with methods that have parameters. I don't know
if that should be enforced.
Rodrigo: Notice that I added BooCodeBuilder.CreateConstructor(TypeMemberModifiers).
Terrific, Sorin.
One thing though, I think attribute expansion should be completely and explicitly tested, see how I did with SingletonAttributeTestFixture or CollectionAttributeTestFixture. I think it's reassuring to see exactly what an attribute is doing to my code not only its side effects.
Great job!