From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.user Subject: Re: call/cc does not return a value Date: Fri, 13 Sep 2024 10:25:05 +0200 Message-ID: References: Reply-To: mikael@djurfeldt.com Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2228"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user , Mikael Djurfeldt To: Damien Mattei Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Fri Sep 13 10:25:52 2024 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 1sp1cm-0000UD-Cb for guile-user@m.gmane-mx.org; Fri, 13 Sep 2024 10:25:52 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sp1cJ-00069T-KQ; Fri, 13 Sep 2024 04:25:23 -0400 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 1sp1cG-00069I-RO for guile-user@gnu.org; Fri, 13 Sep 2024 04:25:21 -0400 Original-Received: from mail-vs1-f51.google.com ([209.85.217.51]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sp1cD-0006fo-NB for guile-user@gnu.org; Fri, 13 Sep 2024 04:25:19 -0400 Original-Received: by mail-vs1-f51.google.com with SMTP id ada2fe7eead31-49bd7809c84so195829137.0 for ; Fri, 13 Sep 2024 01:25:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726215916; x=1726820716; h=content-transfer-encoding:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=P9JUzzY+y/W6BvfBV4oWYKPx24Wg5BASrn2M5uyym+Y=; b=WGTslclepSNQeaYDUXZYjh3iO+syq1pvNKnm8Ivm4dJwDurLRMqCuENoYM2Z5N8/IS Uusp4zVd+VsOj+V8S5DkbCEfJJWo0tjDq2s+UppT5l8zWxY8AqOg6c0DNah6m/OQ2jH5 wSnltq2kXb1PTowjMSdYAA+qPae25Hy5wtezMU4qCAm8REgHm6cFNOQRpT0h8y518QLj pCAl0K3subQYqhQUsVQIKIq9PeJn2en70KPVUx7me08bb1ZXhihp5paC5atp7pjKmWh/ biiI/aUfLNcDPBEjwvHF3C4QXH9HGBzK5FzCA7hfiwoHUgJ8J9DewUys3YR+GVKbpPG7 vKng== X-Gm-Message-State: AOJu0YxOBSH3Eg6BV5l+BHc+ncVshSJ/qcAU7LHoonUUxomplKdK+lVq gv/yYEpner4WNYo1a7FYUYQ+qj0RscXIbdrG1vYDDsijcWK4bHQBVx6j6VbY++tuJ8uDVl1noeu 1jjjtX/rcN/2zDfRNwGiXmzhebMr8u6N9 X-Google-Smtp-Source: AGHT+IGre4vzHOEh1o4gTYIloSOJtacxeCHdN5X2CioPVQUItoZdsZf4g9igzCAlxlUI3ooFY0TNnfY0rCOVsRHSF+o= X-Received: by 2002:a05:6102:952:b0:498:c163:88 with SMTP id ada2fe7eead31-49d4f60ec66mr1557285137.13.1726215915940; Fri, 13 Sep 2024 01:25:15 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=209.85.217.51; envelope-from=mdjurfeldt@gmail.com; helo=mail-vs1-f51.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:19800 Archived-At: Hi Damien, Maybe I'm missing something, but shoudn't it be: (define-syntax for (lambda (stx) (syntax-case stx () ((kwd (init test incrmt) body ...) (with-syntax ((BREAK (datum->syntax (syntax kwd) 'break)) (CONTINUE (datum->syntax (syntax kwd) 'continue))) (syntax (call/cc (lambda (escape) (let ((BREAK escape)) init (let loop () (when test (call/cc (lambda (next) (let ((CONTINUE next)) (let () ;; allow definitions body ...)))) ; end call/cc incrmt (loop))) ; end let loop ))))) ;; close with-syntax )))) ? On Fri, Sep 13, 2024 at 8:53=E2=80=AFAM Damien Mattei wrote: > > hello, > > i believed call/cc allowed to return value but i have this macro and i ca= n > use continuation, but the value is not passed to the continuation: > > (define-syntax for > (lambda (stx) > (syntax-case stx () > ((kwd (init test incrmt) body ...) > > (with-syntax ((BREAK (datum->syntax (syntax kwd) 'break)) > (CONTINUE (datum->syntax (syntax kwd) 'continue))) > > (syntax > (call/cc > (lambda (escape) > (let-syntax ((BREAK (identifier-syntax (escape)))) > init > (let loop () > (when test > (call/cc > (lambda (next) > (let-syntax ((CONTINUE (identifier-syntax (next)))) > (let () ;; allow definitions > body ...)))) ; end call/cc > incrmt > (loop))) ; end let loop > ))))) ;; close with-syntax > )))) > > > mattei@acer:~$ guile > GNU Guile 3.0.9 > Copyright (C) 1995-2023 Free Software Foundation, Inc. > > Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. > This program is free software, and you are welcome to redistribute it > under certain conditions; type `,show c' for details. > > Enter `,help' for help. > scheme@(guile-user)> (use-modules (Scheme+)) > WARNING: (Scheme+): imported module (if-then-else) overrides core binding > `if' > WARNING: (Scheme+): imported module (when-unless) overrides core binding > `when' > WARNING: (Scheme+): imported module (when-unless) overrides core binding > `unless' > > scheme@(guile-user)> (for ((define i 0) (< i 5) (set! i (+ i 1))) (define= x > 7) (display i) (newline) (when (=3D i 2) (break "finish"))) > 0 > 1 > 2 > > here i should get "finish" at REPL but nothing happens? > > regards