From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Subprojects in project.el (Was: Eglot, project.el, and python virtual environments) Date: Fri, 2 Dec 2022 03:32:42 +0200 Message-ID: References: <87zgcq68zp.fsf@ericabrahamsen.net> <87o7t2vj19.fsf@dfreeman.email> <877czqtyfy.fsf@dfreeman.email> <87zgcml7g7.fsf@gmail.com> <2ba04533-097a-a1da-ff3f-2c9506fd488e@yandex.ru> <875yf9bbzb.fsf@gmail.com> <87wn7oa0aw.fsf@gmail.com> <7a5b76fd-fb15-8c1e-ea29-bf11f7e0d2ae@yandex.ru> <87bkoya815.fsf@gmail.com> <0024a67d-b8e5-b35c-1b22-82541a170eb3@yandex.ru> <871qptai4d.fsf_-_@gmail.com> <83o7swyipe.fsf@gnu.org> <83sfi7v6dj.fsf@gnu.org> <45549e6b-942f-ee99-9123-8176545a159e@yandex.ru> <83zgceu8ch.fsf@gnu.org> <7c34024e-c2b6-033f-ff37-a0fdfc9f0cdb@yandex.ru> <83v8n2tbur.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17715"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: monnier@iro.umontreal.ca, danny@dfreeman.email, eric@ericabrahamsen.net, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 02 02:33:55 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0uw5-0004P8-Vq for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Dec 2022 02:33:54 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0uv6-0006Pb-1r; Thu, 01 Dec 2022 20:32:52 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0uv4-0006PT-GI for emacs-devel@gnu.org; Thu, 01 Dec 2022 20:32:50 -0500 Original-Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0uv2-0007e6-8J; Thu, 01 Dec 2022 20:32:50 -0500 Original-Received: by mail-wr1-x42d.google.com with SMTP id m14so5657785wrh.7; Thu, 01 Dec 2022 17:32:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=9+LH+AVPfDSF+A6Id5Npe8yVOWdtQ6t5Thx5GWddkw4=; b=GPX639NHScFpK/RggeQB7cpO5OLnFJ71jN6YZ2KioxUIS+Iwlpz+fIvzOrOap/SCXy 25OFuAnZ30u1EJOR4lPQbjoC0GdL4lJobP+9/L0FVmqErEAADvDH8v7oHZUp/XvAR4My cM+GBGAGWxXhLsx8A0KeKnt/j4LZApL8wBAXz0Ok48+v6Gpo3/dKeXLjVqXn+MS1TWOC yAR62AUxY0nUx2JQ5hwEySqEno8m2jAh28MRVuhBvOn55+Nk/X4hGl5oyJr9fmZMbZKc J0gtsTy7BYoU7s/tw7UmnmS4sEXyRlqM1Bwi8+wiYEivh+AC1yjX0C7QaIfgdWjjxcVd cABQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9+LH+AVPfDSF+A6Id5Npe8yVOWdtQ6t5Thx5GWddkw4=; b=zMy1rDAvRagZweN+4geOj9omyctlELhWGCF36dcejgOkx+fmFCc/zX7E83sPIDlA0T T6NEPSpiXSbqJ0Y1Zu4UI6pOhZhZQ1P/4NjSGqwCWoR/w/0DIiNx3zb/BdXi5dXrIVqG Ezo/aj7kGsvFMvwe9PZZlHbwo9l15h+L0uf/QWhCNpVMdA3CEnoxar4jucDAUPRn0+wS PowFNfNr48QGfWTiX2ItBYe8Om3+fVnb0hIcSRluK+Wh4jH0uLyIKjQWSBP5kKKDEOKh az27ehdRYgI8jlR/8sg5SytgayUIbziQspDoRrf+3Zu3VosG1s+oPAmaFMfKAhhiZvnb CAAQ== X-Gm-Message-State: ANoB5pnZ8mritE4W3YkehDAlsWc/YggphRJzpozCLXyxc53bCrkSqz7D UDn5bf1fHc4XEWN+bUIEgihFP+/7krw= X-Google-Smtp-Source: AA0mqf6A4ovQQAJRtVfIcm87IlaN40O8385+DXj+efRIYCemF7TtdHdGjt6QUut8raHrAddt/R3B9A== X-Received: by 2002:adf:ffd2:0:b0:236:59ab:cf33 with SMTP id x18-20020adfffd2000000b0023659abcf33mr42061073wrs.568.1669944765367; Thu, 01 Dec 2022 17:32:45 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id j33-20020a05600c1c2100b003b4ff30e566sm12434208wms.3.2022.12.01.17.32.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Dec 2022 17:32:44 -0800 (PST) Content-Language: en-US In-Reply-To: <83v8n2tbur.fsf@gnu.org> Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=raaahh@gmail.com; helo=mail-wr1-x42d.google.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.257, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300827 Archived-At: Hi again, It's probably time to continue here. On 26/11/2022 09:26, Eli Zaretskii wrote: >>> Again, you are talking about project kinds already supported by project.el >>> as its built-ins. I'm asking how to produce a project of a custom type. >> >> To produce a project of custom type, you decide the data structure for >> that type, write implementations for all the required (and perhaps some >> optional) generic methods, then create that structure. > > It seems I need to spell out everything every time I'm writing something > because otherwise you interpret it out of context. So here: I'm asking how > to produce a customized project whose type is 'transient', but which doesn't > go by the rules of the built-in 'transient' project. I'm trying to be precise both to avoid misunderstanding. Even here you were using the terminology that seems to conflict with established practice. IIUC, you want to produce a project whose type is not 'transient', but which inherits from 'transient' some of its behaviors. > As for "project of custom type", where "custom" means "not one of the known > types", there's still a situation where my project is similar enough to one > of the built-in types to make reimplementation of all the APIs overkill. > One could want to use some of the APIs without change and customize others. > So this, too, is something that project.el should IMO allow without too much > fuss. So, what you are asking for is perfectly reasonable in theory. Also the current theory of OOP suggests that type inheritance comes with its downsides as well. For instance, the straightforward way Joao was suggesting (create a defclass) will mean nailing down the internal structure of a type which would make it more difficult to create internal changes to it -- because somebody might have inherited from it, and might be using the exposed fields, etc. Asking for a public constructor, however, can help in this regard as well, if you understand how to implement delegation using it. Meaning, you would still create your own type, but then to delegate the implementations of methods you would create an instance of the type to delegate to, and call said methods on it. This the type's evolution would only be limited by the backward compatibility of its constructor. >> You asked, however, how to instantiate a project of a type belonging to >> "someone else". But didn't explain why. > > The "why" is "because one needs to". The question also sounded odd because there is little point to "inherit" from 'transient'. Because that type's definition is only two lines: (cl-defmethod project-root ((project (head transient))) (cdr project)) There is literally nothing to reuse. The rest of that type's behaviors reside in the default definitions of other generic functions. So you can just create your own type, create its method for the above generic function, and then override the rest of the behaviors as needed. If you wanted to inherit from the 'VC-aware' backend, however, that is a different discussion. I would ask which parts of it you need, and whether you intend to honor the project-vc-* user options, as its methods do. Or whether perhaps you just wanted to reuse the VC-based fast file listing implementation. Which would be a little easier to make public with an established signature. >> The reasons not to rely on internal structure, as a reminder: >> >> - The internal structures are prone to change, and you don't want your >> code to break when that happens. >> - When implementing some feature that works with projects, you generally >> want it to work with all kinds of projects (which was the whole point of >> project.el -- to make this approach work). And that would mean talking >> to them through common methods, rather that examine the internals of >> this or that project type. > > I'm fine with all that, but it sounds like the above makes it impossible to > implement custom project objects, maybe because there's no make-project > method that one could use and/or subclass. I usually answer this way because often it's not a good idea, and there are better ways to reach the goals of the person who's asking. Still, if you do want to inherit from 'VC-aware', we can make a public constructor for it. Probably after Emacs 29 is released, and we can see that the structure is settled (it's looking this way now). As for 'transient', well, the constructor can be added as well. The structure is stable and least likely to change; unless we just make an executive decision to turn them all into structs or whatever. I just didn't want to encourage people using it -- even Joao's usage is odd because he not only calls the 'project-root' function, but also 'project-files', and it's just luck that its behavior suits his current goals.