unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Blake Shaw <blake@reproduciblemedia.com>
To: David Pirotte <david@altosw.be>
Cc: Maxime Devos <maximedevos@telenet.be>, guile-devel@gnu.org
Subject: Re: [PATCH v3] docs/match: pattern matcher example makeover
Date: Fri, 03 Feb 2023 17:05:11 +0700	[thread overview]
Message-ID: <7zk00zkoqc.fsf@reproduciblemedia.com> (raw)
In-Reply-To: <20230202144720.306d1bb3@aicha>


David Pirotte <david@altosw.be> writes:
> Not at all - and quite annoying. imo.
> So i'd 'vote' not to use them anywhere in the guile reference manual

take the following functions in both styles:

(let unwrap ((peel '(((((unnest arbitrary nestings))))))) 
  (match-let* (((core ...)) peel)
	       ((wrapper ...) core))
    (if (> (length wrapper) 1) 
	wrapper 
	(unwrap wrapper))))

(let ()
  (define-record-type person
    (make-person name friends)
    person?
    (name    person-name)
    (friends person-friends))

  (letrec ((alice (make-person "Alice" (delay (list bob))))
           (bob (make-person "Bob" (delay (list alice)))))
    (match alice
      (($ person name (= force (($ person "Bob"))))
       (list 'friend-of-bob name)))))

(let unwrap ([peel '(((((unnest arbitrary nestings)))))]) 
  (match-let* ([([core ...]) peel]
	       [(wrapper ...) core])
    (if (> (length wrapper) 1) 
	wrapper 
	(unwrap wrapper))))

(let ()
  (define-record-type person
    (make-person name friends)
    person?
    (name    person-name)
    (friends person-friends))

  (letrec ([alice (make-person "Alice" (delay (list bob)))]
           [bob   (make-person "Bob" (delay (list alice)))] 
    (match alice
      [($ person name (= force (($ person "Bob"))))
       (list 'friend-of-bob name)])))

Without copy and pasting, which have errors, and where?

My wager is that unless you are already quite well adjusted
to lisp, its much easier to catch the errors in the "Indiana"
style examples, and if you are quite well adjusted to lisp,
you aren't really impacted by these conventions in documentation
in any concrete, meaninglful way. 

> It makes the code appear as if it was another language, and requires
> you train yourself to ignore them - as they actually do _not_ have any
> specific meaning, but nonetheless 'pretend they do', by their mere
> presence, and this causes a reading nuisance.

Well, these conventions can be found throughout the gamut of scheme
literature going back to the 80s, and some of the largest scheme
projects, such as Chez, Racket, etc. employ them. So if you're
getting into Scheme, you'll necessarily encounter them, and if you
haven't been made aware that brackets are syntactic sugar for parens
in Scheme, or if that doesn't become apparent with some quick repl
experimentation, you've probably jumped into pattern matching a bit
too quickly.  

But overall, it seems the objections against the Indiana style here
are primarily concerned with individual, current user/contributor
preferences, rather than out of a concern for the target audience,
which are newcomers.



  reply	other threads:[~2023-02-03 10:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01 13:09 [PATCH v3] docs/match: pattern matcher example makeover Blake Shaw
2023-02-01 16:40 ` Maxime Devos
2023-02-02 17:47   ` David Pirotte
2023-02-03 10:05     ` Blake Shaw [this message]
2023-02-03 12:05       ` Arun Isaac
2023-02-03 13:10         ` Blake Shaw
2023-02-03 13:43     ` Josselin Poiret
2023-02-03 14:14       ` Blake Shaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7zk00zkoqc.fsf@reproduciblemedia.com \
    --to=blake@reproduciblemedia.com \
    --cc=david@altosw.be \
    --cc=guile-devel@gnu.org \
    --cc=maximedevos@telenet.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).