Liking cljdoc? Tell your friends :D

org.clojars.t-yano.lang.protocol


defdelegatedcljmacro

(defdelegated record-name fields & body)

This macro extends defrecord and works in conjunction with defdelegation. By using the same syntax as the defrecord macro to describe protocol implementations, it converts function names into the same format as the protocol function names automatically generated by defdelegation.

(defdelegated RecordName [field1 field2] options body)

The options argument is optional. It is a map with the keys :prefix and :suffix, which specify the strings to be prefixed or suffixed to the function names, respectively. If options is omitted, it defaults to using the hyphen (-) as the prefix, which is the default prefix added by defdelegation.

This macro extends `defrecord` and works in conjunction with `defdelegation`.
By using the same syntax as the `defrecord` macro to describe protocol implementations,
it converts function names into the same format as the protocol function names automatically generated by `defdelegation`.

```clojure
(defdelegated RecordName [field1 field2] options body)
```

The `options` argument is optional.
It is a map with the keys `:prefix` and `:suffix`, which specify the strings to be prefixed or suffixed
to the function names, respectively.
If `options` is omitted, it defaults to using the hyphen (`-`) as the prefix,
which is the default prefix added by `defdelegation`.
sourceraw docstring

defdelegationcljmacro

(defdelegation protocol-name & body)

Enhanced defprotocol Macro in Clojure

Introducing a powerful macro designed to streamline the use of protocols in Clojure, while also ensuring seamless integration with clojure.spec.

Usage:

When utilizing this macro, it automatically generates both a regular function and a protocol function. The beauty of this approach is that it allows developers to harness the capabilities of protocols while maintaining the simplicity and familiarity of regular functions.

Function Naming Convention:

Regular Function The name of the regular function remains identical to the one you define within the macro.

Protocol Function The protocol function's name is derived from the regular function but has a '-' prefix. For instance, if you define a function named process within the macro, the corresponding protocol function will be named -process.

Integration with clojure.spec:

A significant advantage of this macro is its ability to work harmoniously with clojure.spec. You can easily define specs for the automatically generated regular functions. This ensures that tools like instrument function correctly. When the regular function is invoked, it's seamlessly forwarded to the corresponding protocol function, allowing for a consistent and predictable behavior.

Key Takeaway:

This macro offers a refined way to work with protocols in Clojure. By automatically generating both regular and protocol functions, it simplifies the development process and ensures compatibility with clojure.spec.

Examples: (defdelegation IProcess (process [this] (println "Processing..."))))

Enhanced defprotocol Macro in Clojure

Introducing a powerful macro designed to streamline the use of protocols in Clojure,
while also ensuring seamless integration with clojure.spec.

Usage:

When utilizing this macro, it automatically generates both a regular function and a protocol function.
The beauty of this approach is that it allows developers to harness the capabilities of protocols
while maintaining the simplicity and familiarity of regular functions.

Function Naming Convention:

Regular Function
The name of the regular function remains identical to the one you define within the macro.

Protocol Function
The protocol function's name is derived from the regular function but has a '-' prefix.
For instance, if you define a function named process within the macro, the corresponding protocol function will be named -process.

Integration with clojure.spec:

A significant advantage of this macro is its ability to work harmoniously with clojure.spec.
You can easily define specs for the automatically generated regular functions.
This ensures that tools like instrument function correctly. When the regular function is invoked,
it's seamlessly forwarded to the corresponding protocol function, allowing for a consistent and predictable behavior.

Key Takeaway:

This macro offers a refined way to work with protocols in Clojure.
By automatically generating both regular and protocol functions,
it simplifies the development process and ensures compatibility with clojure.spec.

Examples:
(defdelegation IProcess
  (process [this] (println "Processing..."))))
sourceraw docstring

delegatedcljmacro

(delegated & body)

This macro extends the reify macro and works in conjunction with defdelegation. By using the same syntax as the reify macro to describe protocol implementations, it converts function names into the same format as the protocol function names automatically generated by defdelegation.

(delegated ProtocolName options body)

The options argument is optional. It is a map with the keys :prefix and :suffix, which specify the strings to be prefixed or suffixed to the function names, respectively. If options is omitted, it defaults to using the hyphen (-) as the prefix, which is the default prefix added by defdelegation.

This macro extends the `reify` macro and works in conjunction with `defdelegation`.
By using the same syntax as the `reify` macro to describe protocol implementations,
it converts function names into the same format as the protocol function names automatically generated by `defdelegation`.

```clojure
(delegated ProtocolName options body)
```

The `options` argument is optional.
It is a map with the keys `:prefix` and `:suffix`, which specify the strings to be prefixed or suffixed
to the function names, respectively.
If `options` is omitted, it defaults to using the hyphen (`-`) as the prefix,
which is the default prefix added by `defdelegation`.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close