hyperbole-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lexical-binding


From: Robert Weiner
Subject: Re: lexical-binding
Date: Tue, 11 May 2021 20:06:13 -0400

On Tue, May 11, 2021 at 1:57 PM Jean Louis <bugs@gnu.support> wrote:
One problem I had with the development of rcd-template package to
interpolate snippets in the text is that I could not use the function
with lexical-binding true in the package.

But what I could do, is to isolate the function into a separate
package that uses global bindings.

Then if I wish to invoke the `rcd-template' function from other
functions with lexical-binding T, then I had to do 2 things:

- prefix the global variables, in this case I have prefixed it with
  `::' separator, like `wrs::page' as that would appear in the
  template where snippets like ⟦ (gethash "areas_name" wrs::area) ⟧
  would then work. As if I don't prefix it, the chances to collide
  with some other variables are there.

- I have to use `dlet' in those packages with lexical-binding T, as to
  call `eval' function indirectly, that one from outside package
  without lexical-binding T.

Example:

(defun wrs-generate-page (page-id)
  (dlet ((wrs::page (rcd-db-table-id-hash "pages" page-id cf-db))
         (wrs::area (rcd-db-table-id-hash "areas" (gethash "pages_area" wrs::page) cf-db))
         (wrs::type (or (gethash "pages_pagetype" wrs::page) (gethash "areas_pagetype" wrs::area)))

IMHO, GNU Hyperbole could switch to lexical-binding T by using that
method:

- isolate the `eval' functions in separate outside package, without
  lexical-binding T;

- use `dlet' when necessary to pass some information to indirectly
  called `eval'

P.S. This may be presentation of a problem without a problem.

The work to convert Hyperbole code to use lexical binding has begun recently and Stefan, with all his experience, is leading that.  It might have to wait for the next release after V8.0.0 though.

--Bob

reply via email to

[Prev in Thread] Current Thread [Next in Thread]