In Clprolf, an interface is always a contract. This applies both to versions (different implementations of the same concept) and to capacities (common abilities across versions).
Language keywords:
compat_interf_version
compat_interf_capacity
Framework annotations:
@Compat_interf_version
@Compat_interf_capacity
An interface in Clprolf is called a compatibility interface. Its purpose is to guarantee that an object is compatible with a certain contract.
When we declare a variable of an interface type, we are not binding it to a specific class — only to the compatibility defined by that interface.
with_compat
Whenever a variable, parameter, or field uses an interface type, it must be preceded by with_compat
(or @With_compat
in the framework).
This marks the point of loose coupling.
Exception: method return types do not require with_compat
.
@With_compat UserDAO dao;
contracts
The Java keyword implements
is replaced by contracts
.
A class lists all the contracts (interfaces) it fulfills.
In the framework, use @Contracts
.
public class UserDAOImpl implements @Contracts UserDAO {
public User getUser(int id) { /* … */ }
}
A capacity interface describes an ability (an “-able” trait), such as Comparable
.
It extends other interfaces but cannot be implemented directly by a class.
This prevents confusion between versions and capacities.
Every capacity must declare an advice:
In the framework:
@Compat_interf_capacity(Advice.FOR_AGENT_LIKE)
public interface ClpComparable<T> {
int compareTo(T other);
}
In the language:
@Agent_like_advice
or @Worker_like_advice
A version interface that extends a capacity must also declare a class role consistent with the advice.
Example: a Car
interface extending ClpComparable<Car>
and a CarClass
that contracts it.
A version interface defines the abstraction for multiple concrete implementations. It corresponds to the usual case of loose coupling in Java.
compat_interf_version
(or @Compat_interf_version
).@Compat_interf_version
public interface ClpConnection extends Connection {
void close() throws SQLException;
}
@Abstraction
public class MyAwesomeDatabaseConnection implements @Contracts ClpConnection {
public void close() throws SQLException { /* … */ }
}
compat_interf
The keyword compat_interf
is a generic fallback.
It defines an interface without a declared role.
Not recommended, but sometimes useful.
public compat_interf MyMysteriousInterface {
void myStrangeJob(String param);
}
@Forced_int_inh
Clprolf enforces simple and intuitive rules:
Violations can be bypassed explicitly with @Forced_int_inh
, which forces interface inheritance (on a class, an interface, or a specific contract type).
Clprolf also provides optional features to treat interfaces as if they were abstract classes:
nature
instead of extends
.agent
).Special keywords:
version_inh
capacity_inh
This makes interfaces behave like full abstract hierarchies, enabling strong loose coupling in collaborative projects.
public version_inh agent Animal {
void eat(String foodName);
}
public version_inh agent Dog nature Animal {
void bark(int duration);
}
public agent AnimalImpl contracts Animal { … }
public agent DogImpl nature AnimalImpl contracts Dog { … }
@Agent
@Version_inh
public interface Animal {
void eat(String foodName);
}
@Agent
@Version_inh
public interface Dog extends @Nature Animal {
void bark(int duration);
}
Interfaces in Clprolf are always about compatibility:
This approach keeps design clear, consistent, and role-driven, while preserving loose coupling.