From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: add-hook and defvar Date: Tue, 24 Feb 2015 06:29:40 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1134730ed6ed20050fcfa42c X-Trace: ger.gmane.org 1424759388 9892 80.91.229.3 (24 Feb 2015 06:29:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 24 Feb 2015 06:29:48 +0000 (UTC) Cc: emacs-devel To: Stefan Monnier , Artur Malabarba Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 24 07:29:48 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YQ908-0005fk-3J for ged-emacs-devel@m.gmane.org; Tue, 24 Feb 2015 07:29:48 +0100 Original-Received: from localhost ([::1]:46945 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ907-0000zN-FH for ged-emacs-devel@m.gmane.org; Tue, 24 Feb 2015 01:29:47 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ903-0000vo-M8 for emacs-devel@gnu.org; Tue, 24 Feb 2015 01:29:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQ902-0000oV-PS for emacs-devel@gnu.org; Tue, 24 Feb 2015 01:29:43 -0500 Original-Received: from mail-lb0-x236.google.com ([2a00:1450:4010:c04::236]:34121) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ902-0000oN-Hc for emacs-devel@gnu.org; Tue, 24 Feb 2015 01:29:42 -0500 Original-Received: by lbdu14 with SMTP id u14so22815487lbd.1 for ; Mon, 23 Feb 2015 22:29:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:from:date:message-id:subject:to:cc :content-type; bh=bosNjXuSWhZoZPq+KDjmAyOG9GucWVgrblXdWF4PPHc=; b=Fe/Nttk7/njj21ncWiwvmUUZqU8ndLDqxt9ZABFfA2g8SG184KSSXaf9rpC4UhIqWQ xA44vI/ROvVjVHwMbdgNbRG3fd/5g9+Yzx8zUcmGOD2dhTwKmK6fULJYEtAhCJ82sr// 7YSXmBjy2JxYxtEE4aJ+KM2nahHgFJE4myJDu4HTvVlk0BXcjQaVPTsjEtJWJB7JwnHH phSG/oVjkrh0J5qIPfR/V0tqczlLzl86VkBo9eugEhNrAIYUBmnRBvXj4TZsiGKXjCSW 7u9ZiKZVsphTj/Ub+tRoqVH3o1n7D1WQyAvucW//CiHNeBtfmKTum66HNFPgqXDHLzy9 TAqA== X-Received: by 10.153.7.100 with SMTP id db4mr1575166lad.9.1424759381746; Mon, 23 Feb 2015 22:29:41 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::236 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:183440 Archived-At: --001a1134730ed6ed20050fcfa42c Content-Type: text/plain; charset=UTF-8 Stefan Monnier schrieb am Mon Feb 23 2015 at 23:32:20: > >> Another problem is that defvar may simply never be called. > > But isn't it a bug to run-hooks a variable that was never explicitly > > defined? > > All hook functions have always treated "unbound" as equal to nil, so no, > it's not considered a bug to run a hook that's still unbound. > > Basically, given that "unbound == nil", what is a bug is to defvar > a hook with a non-nil default value, unless that hook is predefined > (i.e. is never unbound). > > Is this something the byte compiler could warn about? At least normal hooks by convention end in "-hook", so a warning could be emitted every time such a variable is defined that doesn't have nil as default. --001a1134730ed6ed20050fcfa42c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Stefan Monnier <monnier@iro.umontreal.ca> sc= hrieb am Mon Feb 23 2015 at 23:32:20:
>= ;> Another problem is that defvar may simply never be called.
> But isn't it a bug to run-hooks a variable that was never explicit= ly
> defined?

All hook functions have always treated "unbound" as equal to nil,= so no,
it's not considered a bug to run a hook that's still unbound.

Basically, given that "unbound =3D=3D nil", what is a bug is to d= efvar
a hook with a non-nil default value, unless that hook is predefined
(i.e. is never unbound).


Is this something the byte compiler could = warn about? At least normal hooks by convention end in "-hook", s= o a warning could be emitted every time such a variable is defined that doe= sn't have nil as default.=C2=A0
--001a1134730ed6ed20050fcfa42c--