From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: unexpected byte-compiler behaviour Date: Thu, 9 Mar 2017 13:55:12 -0800 Message-ID: References: <20170309174614.GA3572@workstation> <20170309192503.GB2999@workstation> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1489096583 29849 195.159.176.226 (9 Mar 2017 21:56:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 9 Mar 2017 21:56:23 +0000 (UTC) Cc: hector To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 09 22:56:19 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cm62i-0006xt-FH for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Mar 2017 22:56:16 +0100 Original-Received: from localhost ([::1]:36428 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cm62o-0004eF-Jy for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Mar 2017 16:56:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cm623-0004SK-Ix for help-gnu-emacs@gnu.org; Thu, 09 Mar 2017 16:55:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cm622-0005SR-H6 for help-gnu-emacs@gnu.org; Thu, 09 Mar 2017 16:55:35 -0500 Original-Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]:36398) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cm622-0005SI-Dl for help-gnu-emacs@gnu.org; Thu, 09 Mar 2017 16:55:34 -0500 Original-Received: by mail-qk0-x22c.google.com with SMTP id 1so141360889qkl.3 for ; Thu, 09 Mar 2017 13:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=QhB/8a7X0RlcXHnbpHZo8rnmxYTlvMSktOvZy0/YouI=; b=kAXQjW6es78HQAvhw6hpW0cVO0xOi7IC1TW0upXDdIL//jE0veDx+Ad9IgbYywk3dj U+o1aBhSrzjAZc++F3d+JW1+OnnzSRgqaT0EANQwcvVPSJI5q7L3y2nhLZmKsrkk8Kxz o9rRwUipwkjuR03N9BqtEZ0R5unXXAb/50udFU2Kc7ha1Vk65IZreKMlM7F3AR9HI4vr gcHDTDJU5/xmxvhN04J85aOOXfM7Cx6t25tY49mYnJ4l8hcu5SukGXbf5B4N/oi0jVaS CcQDe/2M8H2C4iSu6/9xA/kxzCFc1FelJNYyQ7wQ3qZwtudu0FC12WQXTG1p6frzL3i6 wCkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=QhB/8a7X0RlcXHnbpHZo8rnmxYTlvMSktOvZy0/YouI=; b=ZBeEbj8m0slRpIghQ9tphDxcUMyWXE1SnnWwpSvY5eaQU8xSI4am9TBr4WPrvNZvyH x2GDaAfvNYLXrS8UL9rzOeuqK7MBWjZ4GOKSrf8hjgkzIxqq37qO2zHfvwYGonHay4up XK2f6ZebRcMUEnYE9Kaf+NeLaQh5i9bw8hPLo8fZNxwAbkXP/+4tVs6YXqmk88nahNjl Bum9nmWXOp1RIFHo24ASovf1ZJ5RhHKgXsr0EcvGn4fokTE8t3RAqkDQTtqdFFfKl/Up 93VeSS/0W2OBR/fsPAd9tQcn9EpBLzJyzAuiMwzgX+48qZVmPQvGJ69TAgOaT6+EClKS lgfg== X-Gm-Message-State: AMke39kGiWW7BxQ7ZxI8MfGke7YTCdOKdzxX2aB+ipw16T/l0ubLHqF1vs+G7yz9+/VWO4x4iqYmHCl+wesZAQ== X-Received: by 10.200.57.162 with SMTP id v31mr18096815qte.173.1489096533402; Thu, 09 Mar 2017 13:55:33 -0800 (PST) Original-Received: by 10.237.49.162 with HTTP; Thu, 9 Mar 2017 13:55:12 -0800 (PST) In-Reply-To: <20170309192503.GB2999@workstation> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::22c X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112501 Archived-At: hector wrote: > One of the problems here is that I'm thinking in C. That's where I come > from and sometimes it's hard to get accustomed to a new language. > > You don't need to define a function before it is called. That's why > the "function is not defined" message is delayed until the end of parsing. Functions do need to be defined before they're called, just not before the call is compiled. However, macros (like defclass) are expanded at compile time, so they need to be defined before then. > I think perhaps I should use "(require 'eieio): > > (defclass lyqi-abbrev () > ((abbrev :initarg :abbrev) > (collection :initarg :collection) > (start-position :initarg :start-position))) > > But then, is "defclass" defined even if I don't require eieio? Yes - EIEIO isn't preloaded, and defclass isn't autoloaded, so you should (require 'eieio). You can test this by starting a fresh Emacs with "emacs -Q", then evaluate (fboundp 'defclass), which will return nil. Then evaluate (require 'eieio), followed by (fboundp 'defclass) again, which will now return t. As an aside: Often if you're only using a macro like defclass, it would be enough to use (eval-when-compile (require 'eieio)), because the definition is only needed at compile-time. However, from a quick look I think the expansion of defclass will need EIEIO at runtime (e.g. the call to eieio-defclass-internal), so EIEIO is needed at both compile-time and run-time and thus a full (require 'eieio) is called for. John