From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa29.google.com (mail-vk1-xa29.google.com [IPv6:2607:f8b0:4864:20::a29]) by sourceware.org (Postfix) with ESMTPS id 13110385841F for ; Wed, 26 Oct 2022 10:05:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 13110385841F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vk1-xa29.google.com with SMTP id h16so4857086vkn.4 for ; Wed, 26 Oct 2022 03:05:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=k0KAeFdB6/Irgwf2r7owUCY0k8gEKvpNCpgx2x0pq7k=; b=ZZxti8xLg1ZPzHFEzBMJFfe9Le7KarKfZt8Icj62WduHBwzDEmjJP+vBwl2lh7d4az 7DiLoUiQenEWLopdWWMsp5DdrLDyabq3Da8SXEBcFVVVEpksH8wAX/zeX8MWwu8oyuB0 6pPzSIp7MysYUBeBenhKjPl+gpB6abzmqcWsWHyaMNn1tEcVkuLXiMJDspk6K4zTn/HZ Wk42lcP0FkFxFihm2eO+lgcC6dRL4mtWmOqMiW28f8kKnOvN2vh8WuTGtE6NfTCmmed5 M5Kxyz6NAxmhj5628akl3EnMAQFw0zKC0t+gGNQu1IlpgvBnGsfMUtT0hlgRsHfRet/Z 7I/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=k0KAeFdB6/Irgwf2r7owUCY0k8gEKvpNCpgx2x0pq7k=; b=OQO+QSoXUvbPXrD1L6IKAs4Nmo77Mcdh3DISmdhlJM3HmcYPwACGGrmXA3DCtlN7Xw 7+4yMqHGOI58nGdMmVk65o76mN2j32V271KIlNTpjdEA+1BIoHkmqfj9JNqqEkLsZHmJ DEhTJeIRh1lo3m5jRSR/K9NYEDZ+4fmRIRLLT0NadcH1rsE11JSRU5JaAwjQgeTml8Vm Uu2RF3uZ/0TS1Dz8ohU41dXBUMLcABQ/IcZztF78LWZsHYMbBTWfXAZor2Mt7jolAMpw vYWrZyaLFA0zU+itTRufSJ2jccZHXAg6SnaWIYOPcHfwoYRIsTV8eT+rBDtYOX5fUhy1 eVXQ== X-Gm-Message-State: ACrzQf0hISlG9Lx6KwdKAr7u+c36/oVKZYccmLcc1orw6l6L71td9srM wg05jQ0e0I6aWCSKAJtbD784Ui8V6ebpgXwH/lHUm0iWDSY= X-Google-Smtp-Source: AMsMyM5M/mfpJTTFrWI6RIXw4jMXpf4b3+eoak7JHkQZD4MReiV6p5GjpdL5PNxO8Je7+1x84qxdROoBq722wI/ulCE= X-Received: by 2002:a1f:fcc3:0:b0:3b6:6272:6ced with SMTP id a186-20020a1ffcc3000000b003b662726cedmr7874386vki.15.1666778717199; Wed, 26 Oct 2022 03:05:17 -0700 (PDT) MIME-Version: 1.0 From: Panicz Maciej Godek Date: Wed, 26 Oct 2022 12:05:04 +0200 Message-ID: Subject: Unintended printing a variable from a block of code To: kawa@sourceware.org Content-Type: multipart/alternative; boundary="0000000000005ba3b005ebed2911" X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --0000000000005ba3b005ebed2911 Content-Type: text/plain; charset="UTF-8" I just noticed something weird. If I implement a mutable variant of the "map!" function in the following way (define (map! f inout . in*) (let loop ((tip inout) (tips in*)) (if (and (pair? tip) (every pair? tips)) (begin (set! (car tip) (apply f (car tip) (map car tips))) (loop (cdr tip) (map! cdr tips))) inout))) where "every" is defined as (define (every pred lst) (or (null? lst) (and (pred (car lst)) (every pred (cdr lst))))) it essentially works: (let ((l (list 1 2 3 4))) (map! + l l l)) returns (3 6 9 12) Also, I can check that the input list is mutated: (let ((l (list 1 2 3 4))) (map + l l l) l) also returns (3 6 9 12) However, if I repeat the last argument 4 or more times, as in (let ((l (list 1 2 3 4))) (map + l l l l) l) then instead of outputting (4 8 12 16), Kawa outputs (4 8 12 16) (4 8 12 16). So there's probably some debug output accidentally left somewhere. This behavior does not occur if I remove the l variable from the last line of the block, but when I add another expression after that one, the value is still printed to the screen (and it cannot be captured by call-with-output-string overriding either current-output-port or current-error-port), --0000000000005ba3b005ebed2911--