From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: bug#24514: 24.5; Lispy backtraces Date: Sun, 04 Dec 2016 22:41:35 +0200 Message-ID: <83a8cbl94w.fsf@gnu.org> References: <20160922231447.GA3833@odonien.localdomain> <98fbb582-3da4-bd83-a2e9-e341dd7f6140@gmail.com> <20160923075116.GA612@odonien.localdomain> <82e39377-f31b-698c-5a9a-343868686799@gmail.com> <20161202005226.GA4215@odonien.localdomain> <0a69afa7-e9e6-e75f-8e90-6438683db98d@gmail.com> <53ba4534-1ec3-4e4f-d929-1a72f79c1abe@gmail.com> <83mvgblniy.fsf@gnu.org> <143c480c-a9db-7053-4b70-175633197981@gmail.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1480884129 23518 195.159.176.226 (4 Dec 2016 20:42:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 4 Dec 2016 20:42:09 +0000 (UTC) Cc: emacs-devel@gnu.org To: =?windows-1252?Q?Cl=E9ment?= Pit--Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 04 21:42:05 2016 Return-path: Envelope-to: ged-emacs-devel@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 1cDdbo-0004Z2-HI for ged-emacs-devel@m.gmane.org; Sun, 04 Dec 2016 21:42:04 +0100 Original-Received: from localhost ([::1]:35623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDdbn-0000aF-9p for ged-emacs-devel@m.gmane.org; Sun, 04 Dec 2016 15:42:03 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDdbB-0000YO-6S for emacs-devel@gnu.org; Sun, 04 Dec 2016 15:41:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cDdb8-0004nt-5S for emacs-devel@gnu.org; Sun, 04 Dec 2016 15:41:25 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33295) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDdb8-0004no-26; Sun, 04 Dec 2016 15:41:22 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2092 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cDdb6-0007yB-V9; Sun, 04 Dec 2016 15:41:21 -0500 In-reply-to: <143c480c-a9db-7053-4b70-175633197981@gmail.com> (message from =?windows-1252?Q?Cl=E9ment?= Pit--Claudel on Sun, 4 Dec 2016 14:27:59 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:210034 Archived-At: > Cc: emacs-devel@gnu.org > From: Clément Pit--Claudel > Date: Sun, 4 Dec 2016 14:27:59 -0500 > > >> The C implementation of backtrace-frame seems to be linear in the index of the requested frame, so a Lisp implementation of backtrace would be quadratic in the depth of the stack trace. Would a new function backtrace-frames that returns all frames at once be acceptable? > > > > But such a backtrace-frames function would have to be implemented in > > C, right? And you wanted to move the implementation of "backtrace" to > > Lisp, AFAIU. So it sounds like we will be replacing one C primitive > > with another, or did I miss something? > > I think you're correct. It would seem good to have the flexible primitive backtrace-frames available, and it must be in C; then we can move backtrace itself to lisp. > > The idea is that enumerating frames must be done in C, but printing them doesn't need to be done there. So would it perhaps make sense to rename 'backtrace' into something like 'backtrace--internal', and make it accept one more argument, the function to apply to each frame, which is now hard-coded as 'prin1'? Would that allow you to implement 'backtrace' in Lisp and also implement whatever application you had in mind, by calling 'backtrace--internal' passing it your own function instead of 'prin1'?