Nп/п : 4 из 93
 От   : Kaz Kylheku                         2:5075/128        08 июн 23 17:37:40
 К    : Spiros Bousbouras                                     08 июн 23 20:39:12
 Тема : Re: Estimate: How man Forth-LOCs (line of code) for 10000 C-LOCs ?
----------------------------------------------------------------------------------
                                                                                 
@MSGID: <20230608101719.811@kylheku.com> 8f3e024c
@REPLY: <nzRJAvWCQBiyNSZoM@bongo-ra.co> 3cf91d4f
@REPLYADDR Kaz Kylheku <864-117-4973@kylheku.com>
@REPLYTO 2:5075/128 Kaz Kylheku
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID: <20230608101719.811@kylheku.com>
@RFC-References:
<2bcb3a48-7082-4d29-9496-829749a5403cn@googlegroups.com> <00e4b748-0cc2-4143-9cd4-ebcb443feb43n@googlegroups.com>
<20230607130305.691@kylheku.com> <nzRJAvWCQBiyNSZoM@bongo-ra.co>
@TZUTC: -0000
@PID: slrn/1.0.3 (Linux)
@TID: FIDOGATE-5.12-ge4e8b94
On 2023-06-08, Spiros Bousbouras <spibou@gmail.com> wrote:
> On Wed, 7 Jun 2023 20:26:03 -0000 (UTC)
> Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>> The quasiquote is a templating language for creating nested
>> lists using a notation which looks like those lists, rather
>> than hard-to-read nested constructor calls.
>> A quasiquote can be nested and it can insert material into
>> any level of nesting.
>> 
>> This templating notation is heavily used in writing macros,
>> and other code-to-code transformation situations.
>> Sometimes it is used in manipulating data which isn`t code, too.
>
> For 2 or more levels of nesting , I find it a lot more readable
> to use explicit calls instead of nested backquotes.

Sure, but I was mostly referring to just nested structure in
one backquote, not nested backquotes, as in:

 `(let ((,var ,init) ,@body))

compared to

 (list* `let (list (list var init)) body)

or, worse:

 (append `(let) (list (list (list var init))) body)


> With the
> explicit calls , you push all the quoting to the innermost level
> and otherwise the usual evaluation rules apply. It usually is
> more verbose but I find it more readable.

I`m sure it`s readable, but you probably can`t grok the shape of what is
being built as well.

  (defmacro write-another-macro (name arg)
    `(defmacro ,name (other-arg)
       `(whatever ... ,other-arg ... ,`,arg)))

On the other hand, the problem with nested backquotes is that if you
have to do any of the following, then you may have to stare at them and
pick them apart:

- Debug a non-working nested backquote.

- Convince yourself that a suspicious nested backquote is
  correct (or not) just by looking at it rather than testing.

- Understand what a backquote is supposed to do in some
  undocumented situation.

If these are not issues, the nested backquote does a good
job of conveying the structure of what is being built.

If you`re used to a few idioms like ,`,outer and whatnot,
it helps with the readability.

I remember that I really stuggled with this defset-expander
function:

which has triple backquoting.

https://www.kylheku.com/cgit/txr/tree/stdlib/defset.tl#n59

However, I don`t feel it would have been easier if I tried
to do it without quasiquoting. Even if it were, it would probably
be indecipherable to later scrutiny.

But if you were to change a comma here or there, I wouldn`t know by
looking at it.

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
M..astodon: @Kazinator@mstdn.ca
--- slrn/1.0.3 (Linux)
 * Origin: A noiseless patient Spider (2:5075/128)
SEEN-BY: 5005/49 5015/255 5019/40 5020/715 848 1042
4441 12000 5030/49 1081
SEEN-BY: 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх