* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
[not found] <E1V8wyP-0003i5-8r@vcs.savannah.gnu.org>
@ 2013-08-13 1:56 ` Stefan Monnier
2013-08-13 2:50 ` Eli Zaretskii
0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2013-08-13 1:56 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen; +Cc: emacs-devel
> + (when (and (fboundp 'zlib-available-p)
> + (zlib-available-p))
> + (zlib-decompress-region (point-min) (point-max))
Could you clarify the difference between:
(fboundp 'zlib-available-p)
and
(zlib-available-p)
and
(fboundp 'zlib-decompress-region)
IOW, when can they return different values, and why?
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 1:56 ` [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data Stefan Monnier
@ 2013-08-13 2:50 ` Eli Zaretskii
2013-08-13 3:45 ` Juanma Barranquero
2013-08-13 14:41 ` Stefan Monnier
0 siblings, 2 replies; 15+ messages in thread
From: Eli Zaretskii @ 2013-08-13 2:50 UTC (permalink / raw)
To: Stefan Monnier; +Cc: larsi, emacs-devel
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Mon, 12 Aug 2013 21:56:11 -0400
> Cc: emacs-devel@gnu.org
>
> > + (when (and (fboundp 'zlib-available-p)
> > + (zlib-available-p))
> > + (zlib-decompress-region (point-min) (point-max))
>
> Could you clarify the difference between:
>
> (fboundp 'zlib-available-p)
> and
> (zlib-available-p)
> and
> (fboundp 'zlib-decompress-region)
>
> IOW, when can they return different values, and why?
The 2 fboundp tests return non-nil when Emacs was built with zlib
support. zlib-available-p can return nil on MS-Windows, when the zlib
shared library is not available, even though Emacs was built with zlib
support. On platforms other than Windows, the fboundp tests and
testing the return value of zlib-available-p are equivalent.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 2:50 ` Eli Zaretskii
@ 2013-08-13 3:45 ` Juanma Barranquero
2013-08-13 4:24 ` Stephen J. Turnbull
2013-08-13 9:54 ` Lars Magne Ingebrigtsen
2013-08-13 14:41 ` Stefan Monnier
1 sibling, 2 replies; 15+ messages in thread
From: Juanma Barranquero @ 2013-08-13 3:45 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Lars Ingebrigtsen, Stefan Monnier, Emacs developers
On Tue, Aug 13, 2013 at 4:50 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> The 2 fboundp tests return non-nil when Emacs was built with zlib
> support. zlib-available-p can return nil on MS-Windows, when the zlib
> shared library is not available, even though Emacs was built with zlib
> support. On platforms other than Windows, the fboundp tests and
> testing the return value of zlib-available-p are equivalent.
In other words, portable elisp code should really do
(and (fboundp 'zlib-available-p) (zlib-available-p))
to check for zlib support. Perhaps it would be worth to encapsulate
that check into (yet another) predicate...
J
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 3:45 ` Juanma Barranquero
@ 2013-08-13 4:24 ` Stephen J. Turnbull
2013-08-13 9:54 ` Lars Magne Ingebrigtsen
1 sibling, 0 replies; 15+ messages in thread
From: Stephen J. Turnbull @ 2013-08-13 4:24 UTC (permalink / raw)
To: Juanma Barranquero
Cc: Eli Zaretskii, Emacs developers, Lars Ingebrigtsen,
Stefan Monnier
Juanma Barranquero writes:
> In other words, portable elisp code should really do
>
> (and (fboundp 'zlib-available-p) (zlib-available-p))
>
> to check for zlib support. Perhaps it would be worth to encapsulate
> that check into (yet another) predicate...
XEmacs has an if-fboundp macro which does the above, but it's ugly.
I prefer extending the #'featurep mechanism to optionally do such
checks. Eg,
;;; There's Fprovide(symbol) and Fput(Fintern("symbol"),
;;; Fintern("availability-predicate"),
;;; availability_predicate_DEFUN_symbol))
;;; conditionally compiled on --with-symbol in the startup code.
(defun feature-available-p (symbol)
(and (featurep symbol)
;; I'm a ba-a-ad boy.
(funcall (get symbol 'availability-predicate (lambda ())))))
Contributed to XEmacs under my agreement with the FSF. Ie, now
copyright 2013 FSF. There may be better ways of spelling all this, of
course.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 3:45 ` Juanma Barranquero
2013-08-13 4:24 ` Stephen J. Turnbull
@ 2013-08-13 9:54 ` Lars Magne Ingebrigtsen
2013-08-13 16:02 ` Eli Zaretskii
1 sibling, 1 reply; 15+ messages in thread
From: Lars Magne Ingebrigtsen @ 2013-08-13 9:54 UTC (permalink / raw)
To: Juanma Barranquero; +Cc: Eli Zaretskii, Stefan Monnier, Emacs developers
Juanma Barranquero <lekktu@gmail.com> writes:
> In other words, portable elisp code should really do
>
> (and (fboundp 'zlib-available-p) (zlib-available-p))
Yeah. But I think that `zlib-available-p' should probably always be
defined. And return the correct answer, that is.
So it should be move out of the #ifdef HAVE_ZLIB region, although that
requires a bit more rejuggling; what with calling syms_of_decompress
always etc.
--
(domestic pets only, the antidote for overdose, milk.)
No Gnus T-Shirt for sale: http://ingebrigtsen.no/no.php
and http://lars.ingebrigtsen.no/2013/08/twenty-years-of-september.html
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 2:50 ` Eli Zaretskii
2013-08-13 3:45 ` Juanma Barranquero
@ 2013-08-13 14:41 ` Stefan Monnier
2013-08-13 14:47 ` Paul Eggert
2013-08-13 16:25 ` Eli Zaretskii
1 sibling, 2 replies; 15+ messages in thread
From: Stefan Monnier @ 2013-08-13 14:41 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: larsi, emacs-devel
> The 2 fboundp tests return non-nil when Emacs was built with zlib
> support. zlib-available-p can return nil on MS-Windows, when the zlib
> shared library is not available, even though Emacs was built with zlib
> support. On platforms other than Windows, the fboundp tests and
> testing the return value of zlib-available-p are equivalent.
Can't we get rid of zlib-available-p entirely.
Just replace
(if (and (fboundp 'zlib-available-p) (zlib-available-p))
(zlib-decompress-region ...)
blabla)
with
(condition-case nil
(zlib-decompress-region ...)
((void-function zlib-not-available)
blabla))
Hmm... but the above is not recognized by the byte-compiler either, so
you'll still see the spurious warning :-(
The best would really be
(if (fboundp 'zlib-decompress-region)
(zlib-decompress-region ...)
blabla)
but I guess we can't have that because we also want to lazy-load the
zlib shared library, right?
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 14:41 ` Stefan Monnier
@ 2013-08-13 14:47 ` Paul Eggert
2013-08-13 16:27 ` Eli Zaretskii
2013-08-13 16:25 ` Eli Zaretskii
1 sibling, 1 reply; 15+ messages in thread
From: Paul Eggert @ 2013-08-13 14:47 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Eli Zaretskii, larsi, emacs-devel
Stefan Monnier wrote:
> The best would really be
>
> (if (fboundp 'zlib-decompress-region)
> (zlib-decompress-region ...)
> blabla)
>
> but I guess we can't have that because we also want to lazy-load the
> zlib shared library, right?
fboundp itself could do the lazy load, no?
Or we could have an fboundp variant that
does that. That way, we don't need to have
a FOO-available-p function for every loadable
library FOO.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 9:54 ` Lars Magne Ingebrigtsen
@ 2013-08-13 16:02 ` Eli Zaretskii
2013-08-13 16:10 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2013-08-13 16:02 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen; +Cc: lekktu, monnier, emacs-devel
> From: Lars Magne Ingebrigtsen <larsi@gnus.org>
> Cc: Eli Zaretskii <eliz@gnu.org>, Stefan Monnier <monnier@iro.umontreal.ca>, Emacs developers <emacs-devel@gnu.org>
> Date: Tue, 13 Aug 2013 11:54:58 +0200
>
> I think that `zlib-available-p' should probably always be defined.
> And return the correct answer, that is.
>
> So it should be move out of the #ifdef HAVE_ZLIB region, although that
> requires a bit more rejuggling; what with calling syms_of_decompress
> always etc.
Exactly. And, since neither gnutls.c nor xml.c do anything like that,
I've decided not to.
If we want the available-p predicates be always, err..., available,
then IMO we should do that in those two files as well.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 16:02 ` Eli Zaretskii
@ 2013-08-13 16:10 ` Lars Magne Ingebrigtsen
0 siblings, 0 replies; 15+ messages in thread
From: Lars Magne Ingebrigtsen @ 2013-08-13 16:10 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: lekktu, monnier, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> So it should be move out of the #ifdef HAVE_ZLIB region, although that
>> requires a bit more rejuggling; what with calling syms_of_decompress
>> always etc.
>
> Exactly. And, since neither gnutls.c nor xml.c do anything like that,
> I've decided not to.
>
> If we want the available-p predicates be always, err..., available,
> then IMO we should do that in those two files as well.
Yes, I think we should. First calling fboundp and then -available-p
isn't as clear as just calling -available-p, in my opinion.
Establishing a pattern where we always know that we just have to call
-available-p for any (optional) C libraries seems pretty nice.
--
(domestic pets only, the antidote for overdose, milk.)
No Gnus T-Shirt for sale: http://ingebrigtsen.no/no.php
and http://lars.ingebrigtsen.no/2013/08/twenty-years-of-september.html
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 14:41 ` Stefan Monnier
2013-08-13 14:47 ` Paul Eggert
@ 2013-08-13 16:25 ` Eli Zaretskii
2013-08-13 16:30 ` Lars Magne Ingebrigtsen
2013-08-13 16:49 ` Stefan Monnier
1 sibling, 2 replies; 15+ messages in thread
From: Eli Zaretskii @ 2013-08-13 16:25 UTC (permalink / raw)
To: Stefan Monnier; +Cc: larsi, emacs-devel
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Tue, 13 Aug 2013 10:41:54 -0400
> Cc: larsi@gnus.org, emacs-devel@gnu.org
>
> Can't we get rid of zlib-available-p entirely.
> Just replace
>
> (if (and (fboundp 'zlib-available-p) (zlib-available-p))
> (zlib-decompress-region ...)
> blabla)
>
> with
>
> (condition-case nil
> (zlib-decompress-region ...)
> ((void-function zlib-not-available)
> blabla))
>
> Hmm... but the above is not recognized by the byte-compiler either, so
> you'll still see the spurious warning :-(
> The best would really be
>
> (if (fboundp 'zlib-decompress-region)
> (zlib-decompress-region ...)
> blabla)
But you assume that whoever needs this test needs it only for calling
zlib-decompress-region. What if there's some feature based on zlib
that entirely makes no sense if zlib is not available? Trying to
decompress a file just to discover this sounds gross to me.
> but I guess we can't have that because we also want to lazy-load the
> zlib shared library, right?
As of revision 113823, zlib-decompress-region itself lazy-loads. So
this problem no longer exists.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 14:47 ` Paul Eggert
@ 2013-08-13 16:27 ` Eli Zaretskii
0 siblings, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2013-08-13 16:27 UTC (permalink / raw)
To: Paul Eggert; +Cc: larsi, monnier, emacs-devel
> Date: Tue, 13 Aug 2013 07:47:58 -0700
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: Eli Zaretskii <eliz@gnu.org>, larsi@gnus.org, emacs-devel@gnu.org
>
> Stefan Monnier wrote:
> > The best would really be
> >
> > (if (fboundp 'zlib-decompress-region)
> > (zlib-decompress-region ...)
> > blabla)
> >
> > but I guess we can't have that because we also want to lazy-load the
> > zlib shared library, right?
>
> fboundp itself could do the lazy load, no?
> Or we could have an fboundp variant that
> does that. That way, we don't need to have
> a FOO-available-p function for every loadable
> library FOO.
There are situations where testing the availability of a feature
without actually invoking the feature makes a lot of sense. See my
other mail for the details.
In any case, we decide to get rid of the *-available-p functions, we
should do the same with images and gnutls.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 16:25 ` Eli Zaretskii
@ 2013-08-13 16:30 ` Lars Magne Ingebrigtsen
2013-08-13 16:49 ` Stefan Monnier
1 sibling, 0 replies; 15+ messages in thread
From: Lars Magne Ingebrigtsen @ 2013-08-13 16:30 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Stefan Monnier, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
> But you assume that whoever needs this test needs it only for calling
> zlib-decompress-region. What if there's some feature based on zlib
> that entirely makes no sense if zlib is not available?
You're right -- url-http sends "Accept-Encoding: gzip" if gzip decoding
is available. So we need -available-p.
> Trying to decompress a file just to discover this sounds gross to me.
I agree totally.
--
(domestic pets only, the antidote for overdose, milk.)
No Gnus T-Shirt for sale: http://ingebrigtsen.no/no.php
and http://lars.ingebrigtsen.no/2013/08/twenty-years-of-september.html
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 16:25 ` Eli Zaretskii
2013-08-13 16:30 ` Lars Magne Ingebrigtsen
@ 2013-08-13 16:49 ` Stefan Monnier
2013-08-13 18:04 ` Eli Zaretskii
1 sibling, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2013-08-13 16:49 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: larsi, emacs-devel
>> but I guess we can't have that because we also want to lazy-load the
>> zlib shared library, right?
> As of revision 113823, zlib-decompress-region itself lazy-loads.
Does that mean we can do
(if (fboundp 'zlib-decompress-region)
(zlib-decompress-region ...)
blabla)
?
-- Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 16:49 ` Stefan Monnier
@ 2013-08-13 18:04 ` Eli Zaretskii
2013-08-13 18:55 ` Stefan Monnier
0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2013-08-13 18:04 UTC (permalink / raw)
To: Stefan Monnier; +Cc: larsi, emacs-devel
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: larsi@gnus.org, emacs-devel@gnu.org
> Date: Tue, 13 Aug 2013 12:49:44 -0400
>
> >> but I guess we can't have that because we also want to lazy-load the
> >> zlib shared library, right?
> > As of revision 113823, zlib-decompress-region itself lazy-loads.
>
> Does that mean we can do
>
> (if (fboundp 'zlib-decompress-region)
> (zlib-decompress-region ...)
> blabla)
>
> ?
If all you want is decompress a region, yes.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data
2013-08-13 18:04 ` Eli Zaretskii
@ 2013-08-13 18:55 ` Stefan Monnier
0 siblings, 0 replies; 15+ messages in thread
From: Stefan Monnier @ 2013-08-13 18:55 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: larsi, emacs-devel
>> >> but I guess we can't have that because we also want to lazy-load the
>> >> zlib shared library, right?
>> > As of revision 113823, zlib-decompress-region itself lazy-loads.
>>
>> Does that mean we can do
>> (if (fboundp 'zlib-decompress-region)
>> (zlib-decompress-region ...)
>> blabla)
>> ?
> If all you want is decompress a region, yes.
Perfect, thanks.
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2013-08-13 18:55 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <E1V8wyP-0003i5-8r@vcs.savannah.gnu.org>
2013-08-13 1:56 ` [Emacs-diffs] trunk r113822: Add a test for decompressing gzipped data Stefan Monnier
2013-08-13 2:50 ` Eli Zaretskii
2013-08-13 3:45 ` Juanma Barranquero
2013-08-13 4:24 ` Stephen J. Turnbull
2013-08-13 9:54 ` Lars Magne Ingebrigtsen
2013-08-13 16:02 ` Eli Zaretskii
2013-08-13 16:10 ` Lars Magne Ingebrigtsen
2013-08-13 14:41 ` Stefan Monnier
2013-08-13 14:47 ` Paul Eggert
2013-08-13 16:27 ` Eli Zaretskii
2013-08-13 16:25 ` Eli Zaretskii
2013-08-13 16:30 ` Lars Magne Ingebrigtsen
2013-08-13 16:49 ` Stefan Monnier
2013-08-13 18:04 ` Eli Zaretskii
2013-08-13 18:55 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.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).