From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matt Wette Newsgroups: gmane.lisp.guile.user Subject: Re: wayland client in Guile without libwayland-client Date: Sat, 19 Nov 2022 06:50:34 -0800 Message-ID: <437221f0-7181-505f-535d-8e0604ef30d5@gmail.com> References: 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="35521"; 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: Guile User To: Damien Mattei , =?UTF-8?Q?Linus_Bj=c3=b6rnstam?= Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Nov 19 15:51:45 2022 Return-path: Envelope-to: guile-user@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 1owPC5-0008zp-GV for guile-user@m.gmane-mx.org; Sat, 19 Nov 2022 15:51:45 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owPB4-0000rH-PD; Sat, 19 Nov 2022 09:50:42 -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 1owPB3-0000r7-LQ for guile-user@gnu.org; Sat, 19 Nov 2022 09:50:41 -0500 Original-Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1owPB1-0002H9-F0 for guile-user@gnu.org; Sat, 19 Nov 2022 09:50:41 -0500 Original-Received: by mail-pf1-x436.google.com with SMTP id 140so7526532pfz.6 for ; Sat, 19 Nov 2022 06:50:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=FjzqbkExVz8afF4911WSKqJ9s9lNe5a3L4qtqnHpaZU=; b=bxYXFb3mf/PJSrXVK6gr3vjSNOeDjt2lPxux5urdHrAG682lmMYbg14ajxiWKpxSN0 khUvb3jfFS4Qe/W8bsVb1qFfB9sKY4BB9ZXvMXC2b12F3gEPEah0Cj2+Q6s40ytHM9TC N19RRQhPCJSm26Z+A4VNMawi+PJzGhr2Jgj4A/cROAdOQJlnw7mW1naF+oOZUZhzWvsE W2CD/RJykiQ8E8qCysg7ejFVDyr2JGZj7d7ljPgwjNSkthDmdSy72T1s0R7GyU1SKmoh gcNL5IGgUUgjwUV6ZwqpgLLCwS3tkj5LparVTa/JgsTjC51nsRxQGtQ9Tch17YP8LWv2 cbYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=FjzqbkExVz8afF4911WSKqJ9s9lNe5a3L4qtqnHpaZU=; b=j4ihbtww1RdtXxq2L/sA1xNlV3TGSUt/mlMQ3DiIhtU8xwfU67L4wK3nVgzBNPQTcK SI4o3gRj8Nnu6opg3kE5ENJ4Pi1QHnNkJ2M3K2OvJ3Vkaygw8cjTSc1G5GOu9EcVw1cE TKAlYdoPYi3411+LBcSbOjqVPwIRvyG/7YCKyH74JNP+xVqBFgBUgzCt8HcqXM+RBYaQ 8WL99ppjumXLZ79IYU3y4KTTtLLhHLcSye02V3Weo10mtraNrkDjWzhPn8XBrNBafodg eDqAceuhcCLz0AlhluVAAwJvjNCSkvFfY7E5jHHIkoUGUQ4h83d0DXwLjUK9jmykhkkR W4Zg== X-Gm-Message-State: ANoB5pnnMedlX4Fbpyaw9MBdL2+Lt9pEkqNDqjjH3urz4gj69n7ruw4T rs5on+QrcoBBnsS+qBRD2+CoiarvW4g= X-Google-Smtp-Source: AA0mqf5YC6yNytolMGFTLlljx4ZVFdJjJy2/n4XS1TWn3e2OcdxRx+3cHqrUjOb/ySpU1cfLAjEu0Q== X-Received: by 2002:a62:1d13:0:b0:56b:a672:6299 with SMTP id d19-20020a621d13000000b0056ba6726299mr12667792pfd.10.1668869437942; Sat, 19 Nov 2022 06:50:37 -0800 (PST) Original-Received: from [192.168.2.158] (64-52-138-37.championbroadband.com. [64.52.138.37]) by smtp.gmail.com with ESMTPSA id o7-20020a1709026b0700b00186a2dd3ffdsm5855269plk.15.2022.11.19.06.50.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 19 Nov 2022 06:50:37 -0800 (PST) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=matt.wette@gmail.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, NICE_REPLY_A=-0.001, 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-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:18742 Archived-At: On 11/18/22 8:26 PM, Damien Mattei wrote: > hello, > > it is just a question about semantic and aside the subject of project, and > related to another subject of internal definitions that Linus is talking > about: > > On Fri, Nov 18, 2022 at 5:55 PM Matt Wette wrote: > >> Here is an example of an auto-coded event decoder: >> >> (lambda (obj-id bv ix cm) >> "event decoder for global" >> (let*-values >> (((name ix) (dec-u32 bv ix)) >> ((interface ix) (dec-string bv ix)) >> ((version ix) (dec-u32 bv ix))) >> (values obj-id name interface version))) >> >> >> > i was just thinking how i would write the procedure above in Scheme+ ( > https://github.com/damien-mattei/Scheme-PLUS-for-Guile ) that has feature > for multiple values. > this code could be rewritten like that: > (lambda (obj-id bv ix cm) > "event decoder for global" > {(name ix) <+ (dec-u32 bv ix)} > {(interface ix) <+ (dec-string bv ix)} > {(version ix) <+ (dec-u32 bv ix)} > (values obj-id name interface version)) > > note that <+ is an "operator" that allows multiple values definitions. > > but it would fails to compile because of multiple redefinition of ix > variable: > > scheme@(guile-user)> (use-modules (Scheme+)) > scheme@(guile-user)> (lambda (obj-id bv ix cm) > "event decoder for global" > {(name ix) <+ (dec-u32 bv ix)} > {(interface ix) <+ (dec-string bv ix)} > {(version ix) <+ (dec-u32 bv ix)} > (values obj-id name interface version)) > While compiling expression: > Syntax error: > unknownfile:7:0: invalid or duplicate identifier in definition in form > (lambda (obj-id bv ix cm) "event decoder for global" (<+ (name ix) (dec-u32 > bv ix)) (<+ (interface ix) (dec-string bv ix)) (<+ (version ix) (dec-u32 bv > ix)) (values obj-id name interface version)) > > a longer and a bit unsightly solution could be: > > (lambda (obj-id bv ix cm) > "event decoder for global" > (declare name interface version) > {(name ix) {(interface ix) {(version ix) (values obj-id name interface version)) > > that would be correct: > > (note just define variables initialised by default with '() in Scheme+) > > scheme@(guile-user)> (lambda (obj-id bv ix cm) > "event decoder for global" > (declare name interface version) > {(name ix) {(interface ix) {(version ix) (values obj-id name interface version)) > ;;; :16:24: warning: possibly unbound variable `dec-u32' > ;;; :17:29: warning: possibly unbound variable `dec-string' > $3 = #:13:0 (obj-id bv ix cm)> > > the first example fails not because of my Scheme+ language extension but > because in scheme redefinition is only allowed at toplevel or in the REPL. > > Would it not be a good idea to allow redefinitions in Scheme and Guile not > only at toplevel or REPL but in procedure definitions and lambda, in their > bodies? > > personaly i can not see any "bad" side effect or consequences... of course > it relax the possibility of code error by unchecking a redefinition of > variable but it is like in C++ where you can define private or protected > variables but even with protective language feature one can wrote bad > code... > > Best regards, > > Damien Another approach might be a state monad (guix has code for this). I am not sure about other implementations, but I am reasonably confident that the Guile compiler can turn my values-heavy Scheme into efficient bytecode. I'm also working to keep allocations down also (e.g., reusing bytevector buffers). Thanks for your interest. Matt