hyperbole-users
[Top][All Lists]
Advanced

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

lexical-binding


From: Jean Louis
Subject: lexical-binding
Date: Tue, 11 May 2021 20:56:20 +0300

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.

I use:  Editor:      GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X 
toolkit, cairo version 1.17.4, Xaw3d scroll bars)

        Hyperbole:   8.0.0pre
        Sys Type:    x86_64-pc-linux-gnu
        OS Type:     gnu/linux
        Window Sys:  x
        News Reader: Gnus v5.13

Quit-- 
Thanks,
Jean Louis

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns




reply via email to

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