Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by mail-b.sr.ht (Postfix) with ESMTPS id C44EBFF114 for <~duangle/scopes@lists.sr.ht>; Sat, 4 Jul 2020 21:28:44 +0000 (UTC) Authentication-Results: mail-b.sr.ht; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ODjQ7Y6g Received: by mail-ej1-f54.google.com with SMTP id dp18so38234954ejc.8 for <~duangle/scopes@lists.sr.ht>; Sat, 04 Jul 2020 14:28:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=lAuaECUDxGvW3mlraAP/roHzqzIcpD1n39ggV9Ymv70=; b=ODjQ7Y6g+Ag5ssWa/hfQP4K0vu2ybkJztL60CXi5mKsxP0WTGdOlaivgK/AlCNmGNZ vT95GjGyxUNKApizTzfcNM+GiTJhAs+SUHLCHLV3d8IawarEITdvYwixtcjylumMA6aj 1Q5MLFCIgj6gQhm18FImoHrUJPC2Uw2t9FA56gad/rIaD37jebKUOEpHS0TyfKC/X8Li 4ieny7XbkPXEXk5o8XcVd72L+SA0UJAscbQk8+Csy7S8/TP248q/XNhLRw+qgPVAhe3n GuSrt2tRMF48a60m7YPXvh5b//cI/12dECgpGwZyOVy6NoL6/3oIS/ktKRhUKfsi3w71 uaAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=lAuaECUDxGvW3mlraAP/roHzqzIcpD1n39ggV9Ymv70=; b=QeVu5VhqB1L7aQD2cLphwT+EMJRnGawHb6W8vwjhMMhI/VvwhjQ/X7bKPPck1KZDXR KX7H/IM8q5kUS+LvgLmP/vhnmu4tnPl5/UXGYSEBttfhHkq6IayKfNlXyYc0TIxoL5dH YtqbcMEYGUR8b2O1UBD+56TKk2vbumRS3MOlmtNKlwaz5enQLjKW18Nwxe1gVaidKOt2 kQrNLqb9YKns3HtHLU14oLwNXKwbPVtY2j8FyVsqVv/8sc4cpuzKh6F8gr3tcor+HdXh P0cHkerVbpY/FWv21mHQAiq5F9qNAJfXlF3Kksq5rXHzb9uUHp+CfLAW2gdumNijmmm5 7Hog== X-Gm-Message-State: AOAM530Gx5N1MZz6xKV5agXeaiwBKd7pKKdAIOClr60oXV3+7v4UUxWy jLbfZR9CPSt9Z0x2kuvySFW7C09ciCHWPdBYrUM= X-Google-Smtp-Source: ABdhPJzz4bmUtRq+B9LOEzDdv5bsYf6U87G7B2QpOsO+9W2vNSCfEOJo/IdoJUWhtQFDsyZDo4QksIGvLRYZkX0S0+s= X-Received: by 2002:a17:906:3c42:: with SMTP id i2mr39924532ejg.14.1593898123683; Sat, 04 Jul 2020 14:28:43 -0700 (PDT) MIME-Version: 1.0 References: <71NYCQ.87F07ED5PFH2@gmail.com> In-Reply-To: <71NYCQ.87F07ED5PFH2@gmail.com> From: Shawn Walker Date: Sat, 4 Jul 2020 14:28:33 -0700 Message-ID: Subject: Re: unexpected behavior with arrays? To: Westerbly Snaydley Cc: ~duangle/scopes@lists.sr.ht Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, 4 Jul 2020 at 12:49, Westerbly Snaydley wrote= : > On Sat, Jul 4, 2020 at 12:34, Shawn Walker > wrote: > > I guess I=E2=80=99m spoiled by the rust compiler=E2=80=99s reasoning ab= out > > lifetimes. If I try to use =E2=80=98x=E2=80=99 once the binding has ex= pired it > > won=E2=80=99t let me and tells me why. Here it seems like Scopes shoul= d > > know the lifetime of the storage and then could prevent or warn about > > further use. > > Scopes' borrow checker is opt-in, and the core is designed such that > lower level constructs / APIs are not checked. The higher level APIs on So if I'm guessing correctly, the borrow checker you're referring to is the "view propagation" mechanism? However, that can't be used with the lower-level constructs and some of the APIs? > the other hand are built on top of those but with security added in. In > this particular example, it's usually recommended to use the Array > (from Array.sc) data-type instead, which is both bounds and lifetime > checked. Similarly alloca, malloc shouldn't be used directly (ie. use > `local` with a unique type, or a Box for heap). I was trying to puzzle out the subtleties between let, local, etc. using examples from the tests. The documentation and test examples made it clear enough that local was stack, global was heap, etc. but let is still murky to me. My understanding is that let is generally register-based allocation for values unless you use something like alloca-x but maybe it's stack too? --=20 Shawn Walker-Salas