SCOOP & Contracts

30 views
Skip to first unread message

lrix

unread,
Jan 11, 2016, 11:20:54 AM1/11/16
to Eiffel Users
Recently, I was reading a research paper from a Canadian university talking about applying something like SCOOP to Java. Because Java does not have  Design-by-Contract, they wanted to build in a new keyword (like "require") called "await". From the writers point of view, the require contract was acting as a gatekeeper on the feature to say, "Wait until this resource is available before executing this routine"—therefore—"await" (as in awaiting resource lock availability).

This made me wonder if a new code section in the Eiffel language notation might not be better—that is—await, such that:

my_feature
   await
      resource_identifier_1
, resource_identifier_2, ...
   
require
     contracts
...
   
do
     
... code ...
   
end



Would this not be better for readability? I am just now starting to learn pragmatic SCOOP and do some implementation(s). So, I cannot speak from experience, but the question came up, so I thought I would ask.


Thanks,

Larry

Alexander Kogtenkov

unread,
Jan 12, 2016, 5:12:20 AM1/12/16
to eiffel...@googlegroups.com
If a resource is shared among different processors and access to it should be exclusive, in SCOOP it is usually put in a separate region. Then passing the resource as an argument does the trick: the feature gets an exclusive access to it. For example,

   r1, r2, r3: separate RESOURCE
   ...
   foo (x, y: separate RESOURCE)
      ...
   bar (x, y: separate RESOURCE)
      ...

   foo (r1, r2) -- Operate on r1 and r2 (no other processor gets access to r1 and r2, but may use r3)
   bar (r2, r3) -- Operate on r2 and r3 (no other processor gets access to r2 and r3, but may use r1)

Regards,
Alexander Kogtenkov


lrix <lr...@jinny.com>:

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.



Miguel Oliveira e Silva

unread,
Jan 18, 2016, 7:04:26 AM1/18/16
to eiffel...@googlegroups.com
Dear Larry,

It would be a bad (and unnecessary) idea to introduce a await clause separated from the precondition clause.
In SCOOP, when a precondition is applied to a separate entity its execution semantics are similar to a conditional synchronization point.  No need for explicit condition variables, awaiting, and notifying as in POSIX or Java (lower level) thread programming.

-miguel
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages