From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.devel Subject: Re: Lisp watchpoints Date: Sun, 29 Nov 2015 14:40:57 -0500 Message-ID: References: <83wpt922dn.fsf@gnu.org> <83egf8oiwt.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1448826074 30597 80.91.229.3 (29 Nov 2015 19:41:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 29 Nov 2015 19:41:14 +0000 (UTC) Cc: John Wiegley , Stefan Monnier , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 29 20:41:09 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 1a37qP-0000XS-7m for ged-emacs-devel@m.gmane.org; Sun, 29 Nov 2015 20:41:09 +0100 Original-Received: from localhost ([::1]:37512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a37qT-0007Xe-5d for ged-emacs-devel@m.gmane.org; Sun, 29 Nov 2015 14:41:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a37qG-0007XR-T4 for emacs-devel@gnu.org; Sun, 29 Nov 2015 14:41:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a37qF-0007oy-VH for emacs-devel@gnu.org; Sun, 29 Nov 2015 14:41:00 -0500 Original-Received: from mail-ig0-x235.google.com ([2607:f8b0:4001:c05::235]:37239) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a37qE-0007oV-Cs; Sun, 29 Nov 2015 14:40:58 -0500 Original-Received: by igcto18 with SMTP id to18so57476147igc.0; Sun, 29 Nov 2015 11:40:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=hkuHYS/WVyP6r9LaT6QKSETsU3bL98CIk+HIw2Y1H9M=; b=ykNw5DeRHz/yUZz7+FGsCGf5aHDFjpsr/oZ8AqbnOZ0uSxCJ/S+yj2Tap4K56n39T1 4JPS0+xQYkuEDIEgqoI3Hi/xz53s0jdALv8ivHrr3Xw6QG/Kib6sSc2vsbjJQPFzvp1+ gIVpN/A3oo3kfh6D6t7OEgX+1RQ20T8sgiq/sOadLl0YK8oesxJvOjqPIumr0ywO7huN k+4n/IJdH6cXF+8UnlXvwGgBQLB3GHihOfhq+0qGyvf32NRpvx44+UeuuNPGXDBVP9M6 M8CNYhovabUJZbhoMZlBfGd2ttaE1q4CxQSkU3JlYAhXW+23HsSqcpEhIpXNqxOePweL Ciow== X-Received: by 10.50.17.38 with SMTP id l6mr6579923igd.58.1448826058027; Sun, 29 Nov 2015 11:40:58 -0800 (PST) Original-Received: by 10.79.119.2 with HTTP; Sun, 29 Nov 2015 11:40:57 -0800 (PST) In-Reply-To: <83egf8oiwt.fsf@gnu.org> X-Google-Sender-Auth: 7H5CZp9jwdxt0hCx_ySF0-Q5TsM X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c05::235 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:195562 Archived-At: On Sun, Nov 29, 2015 at 11:43 AM, Eli Zaretskii wrote: >> +DEFUN ("remove-variable-watcher", Fremove_variable_watcher, Sremove_variable_watcher, >> + 2, 2, 0, >> + doc: /* Cause WATCH-FUNCTION to be called when SYMBOL is set. */) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Copy/paste mistake? Oops. > > The call to ARRAYELTS should be outside of the loop (for those poor > souls who run unoptimized builds most of the time). Compiling the following shows gcc folds the constants even with -O0 (also, notify_variable_watchers() should only be called for a few selected symbols so I don't think it would really slow things down very much). int array[] = { 1, 2, 3, 4 }; /* Number of elements in an array. */ #define ARRAYELTS(arr) (sizeof (arr) / sizeof (arr)[0]) int foo(int x) { if (x < ARRAYELTS(array)) return array[x]; return 0; } > >> static const WATCHER_FUNCTION watcher_table[] = >> { >> + &set_redisplay >> }; >> enum >> { >> + WATCHER_NUMBER_SET_REDISPLAY >> }; > > Shouldn't we make sure WATCHER_NUMBER_SET_REDISPLAY's value is zero? Probably better to be explicit, yes. > >> + DEFVAR_INT ("set-redisplay-internal-watcher-number", >> + Vset_redisplay_internal_watcher_number, >> + doc: /* Internal watch function constant. */); >> + Vset_redisplay_internal_watcher_number = WATCHER_NUMBER_SET_REDISPLAY; >> + make_symbol_constant (intern_c_string ("set-redisplay-internal-watcher-number")); > > I'd prefer if all this were moved to window.c. data.c has no business > with display-related issues. Hmm, then how should we make the connection between watcher numbers and C function pointers? I think data.c should be in charge of that. > > Please also add a short notice for etc/NEWS. Bonus points for adding > some tests. Will do.