unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Oleg Pykhalov <go.wigust@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: 01/01: gnu: cmake: Delete Emacs library.
Date: Wed, 23 May 2018 21:35:20 -0400	[thread overview]
Message-ID: <87sh6h6dk7.fsf@netris.org> (raw)
In-Reply-To: <87y3ga9wty.fsf@gmail.com> (Oleg Pykhalov's message of "Wed, 23 May 2018 19:10:49 +0300")

Hi Oleg,

Oleg Pykhalov <go.wigust@gmail.com> writes:

> Mark H Weaver <mhw@netris.org> writes:
>
>> go.wigust@gmail.com (Oleg Pykhalov) writes:
>>
>>> @@ -85,6 +85,12 @@
>>>             " --exclude-regex ^\\(" (string-join skipped-tests "\\|") "\\)$")))
>>>         #:phases
>>>         (modify-phases %standard-phases
>>> +         (add-after 'unpack 'split-package
>>> +           ;; Remove files that have been packaged in other package recipes.
>>> +           (lambda _
>>> +             (delete-file "Auxiliary/cmake-mode.el")
>>> +             (substitute* "Auxiliary/CMakeLists.txt"
>>> +               ((".*cmake-mode.el.*") ""))))
>>
>> this new phase that you've added returns an unspecified value, although
>> it is supposed to return a boolean to indicate success or failure.
>
> substitute* returns #t if it finds a file and error otherwise.  Do I
> miss understand something?

Yes.  You are confusing the *specification* with the behavior of the
current implementation.  Also, you've reached a mistaken conclusion
about the behavior of the current implementation.

The specification (i.e. documentation) for 'substitute*' says nothing
about its return value.  That's what I mean when I say that its return
value is "unspecified".

> scheme@(guile-user)> (substitute* "/tmp/test.txt" (("Hello") "foo"))
> $3 = #t
> scheme@(guile-user)> (substitute* "/tmp/test.txt" (("bla") "foo"))
> $4 = #t
> scheme@(guile-user)> (substitute* "/tmp/test.txtf" (("bla") "foo"))
> ERROR: In procedure stat:
> In procedure stat: No such file or directory: "/tmp/test.txtf"

Here you've attempted to determine the specification of 'substitute*' by
experiment on a few examples, and on the basis of these results have
apparently concluded that:

  "substitute* returns #t if it finds a file and error otherwise."

In fact, this conclusion is incorrect.  Here's a counterexample:

  scheme@(guile-user)> ,use (guix build utils)
  scheme@(guile-user)> (define return-val
                         (substitute* (list "HACKING" "INSTALL")
                           (("bla") "foo")))
  scheme@(guile-user)> (list return-val)
  $1 = (#<unspecified>)

In general, it's a mistake to try to determine the specification of a
procedure or macro by experiment, or even by analyzing its current
implementation.

Suppose that you examine the current implementation of some procedure
and find that it always returns #t.  Even so, that tells you nothing
about the behavior of future implementations.  If the specification of a
procedure says nothing about its return value, then future implementors
may legitimately feel free to pay no attention to the return value, and
thereby allow the return value to be whatever happens by accident.

That's why the *specification* is what you need to know when using a
procedure or macro.  Knowledge of the current implementation is no
substitute for knowledge of the specification.

Does that make sense?

      Regards,
        Mark


PS: Note that although Guile has a special value #<unspecified> that is
    sometimes returned by expressions whose return value is unspecified,
    as in the counterexample above, in general such expressions could
    return _any_ Scheme value.

  reply	other threads:[~2018-05-24  1:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180522141738.8231.26687@vcs0.savannah.gnu.org>
     [not found] ` <20180522141741.641D120711@vcs0.savannah.gnu.org>
2018-05-22 18:43   ` 01/01: gnu: cmake: Delete Emacs library Mark H Weaver
2018-05-23 16:10     ` Oleg Pykhalov
2018-05-24  1:35       ` Mark H Weaver [this message]
2018-05-25 10:02         ` Oleg Pykhalov
2018-05-26 13:37           ` Marius Bakke
2018-05-28  9:41             ` Ludovic Courtès
2018-05-28  9:55               ` Vincent Legoll
2018-06-16 19:44               ` Marius Bakke

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://guix.gnu.org/

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

  git send-email \
    --in-reply-to=87sh6h6dk7.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=go.wigust@gmail.com \
    --cc=guix-devel@gnu.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).