Boo
  1. Boo
  2. BOO-455

Boo.Lang.Useful.Attributes.OnceAttribute

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.6
    • Component/s: Boo.Lang.Useful
    • Labels:
      None
    • Number of attachments :
      1

      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).

        Activity

        Hide
        Rodrigo B. de Oliveira added a comment -

        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!

        Show
        Rodrigo B. de Oliveira added a comment - 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!
        Hide
        Sorin Ionescu added a comment -

        Bug Fix: Functions defined outside of a type body were not recognized as static.

        Show
        Sorin Ionescu added a comment - Bug Fix: Functions defined outside of a type body were not recognized as static.

          People

          • Assignee:
            Unassigned
            Reporter:
            Sorin Ionescu
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: