What does the :internal-function-template option stands for?

19 views
Skip to first unread message

André Miranda Moreira

unread,
May 14, 2014, 12:52:54 AM5/14/14
to res...@googlegroups.com
What does the :internal-function-template option in define-policy does?

I thought that it would behave like :interface-method-template, but internally, but I think I'm wrong.

I saw that the defaul is the string itself ("~a"), but which string is it?

Orivej Desh

unread,
May 14, 2014, 5:39:42 PM5/14/14
to res...@googlegroups.com
> What does the :internal-function-template option in define-policy does?
>
> I thought that it would behave like :interface-method-template, but
> internally, but I think I'm wrong.

Actually, interface methods are the methods you implement, and internal
functions are the methods you use. In Python terminology, the former
would be called unbound (class) methods, and the latter are bound
(instance) methods.

I hope that this clarifies the terms:

- a "policy" is an "interface" (just as in Lisp Interface Library, https://github.com/fare/lisp-interface-library)
- an "interface" method name is an "implementation" (or "internal") method name
- an "internal" function name is an "interface" function name

For example, in arblog (https://github.com/archimag/arblog/), with original terminology to the left and my terminology to the right:

- core/defmodules.lisp
defines policies | defines interfaces
- datastore/mongodb.lisp
implements interface methods | implements an interface
- core/admin.lisp
uses internal functions | uses interface functions
- examples/simple.lisp
binds internal functions to implementations of interface methods | binds interface functions to interface implementations

Surprising similarity between these namings serves to clarify the original terminology.

André Miranda Moreira

unread,
May 22, 2014, 3:10:04 AM5/22/14
to res...@googlegroups.com
So, if I define a policy (or, as your called it, interface) like this:
(restas:define-policy datastore
  (:interface-package site.policy.datastore)
  (:interface-method-template "DATASTORE-~a")
  (:internal-package site.datastlre)
  (:internal-function-template "DB.~a")

  (define-method get-all ()))

... then, when implementing the  method GET-ALL I should write like:
(defmethod datastore-get-all ...)

... and when using the method inside the application I should write like:
(db.get-all)

Is that correct?

Orivej Desh

unread,
May 22, 2014, 5:54:45 AM5/22/14
to res...@googlegroups.com
Yes, that's right.
Reply all
Reply to author
Forward
0 new messages