Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by mail-b.sr.ht (Postfix) with ESMTPS id 86483FF114 for <~duangle/scopes@lists.sr.ht>; Sat, 4 Jul 2020 21:23:01 +0000 (UTC) Authentication-Results: mail-b.sr.ht; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=E6G12eMl Received: by mail-ed1-f49.google.com with SMTP id e22so31032101edq.8 for <~duangle/scopes@lists.sr.ht>; Sat, 04 Jul 2020 14:23:01 -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=xRDjIF7RY3Ftp1NGzccUj3M+llg9vLz+FRJoqCzBUYo=; b=E6G12eMlHz5ysctpx6g0H+gJcyAFCleRJzSbOZm9wzMzOi2+T0ZjnEe2/vrTM3/F34 VNZPe6TSWBpiJUVbOMwfA5hOtEXQGXfEqUCHM46lkRFPoRBfq72E3l+uZYhRREgJhd95 6/UH7YlhfGfCZkg20b7w3U2azPDulDw9g734Vsa2xr0/zd9Iud9+MqPXfxfaYdACd1A8 tYps/3RdA4c1kXCU4sTy7JFfXFVBL7PaHa1FCFe1usIS3O7fiEbngf4bjrmR5rNbVQkp rd2JBQJdUJn7pVeCr/du45RlVF7TkcbJrSn/0bdwbIybpXzBhAY0THOoYmKkPQo3oq5d j0ZQ== 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=xRDjIF7RY3Ftp1NGzccUj3M+llg9vLz+FRJoqCzBUYo=; b=cMOfXBSNOibKTgjssm+sJoUR605VjqmhH02mdFBjqwehpWhpxQNT9Yu/9AkVRZ0gZy 600cCOCpD0p32Pj6ENJOfMcA6oEqKSkqQRojd7ng5ICgx0fB8kaNt0MEizqT/Yk0NGpp F9a5DeoRhBnSEWAeqVWlwuIGMWmFoPyobYc0tguRgTnvFUGpyDFfy6ztC8g0PozmHzOT JAw36D3GlRprdJy9f4HWSetSwC0giBnyylfxofcP4yRZFavnrFkBAndEuwUKI9KnM6py v3W/IBX2LLcnsT5/uY5ezvk75/TRhS9MGRy/yt7CYAKGjFvzBKE5A20Iz7bnduoPUsnn 9CUg== X-Gm-Message-State: AOAM533vxbdQzW/2NRx4440/bUpgbuD4MtJyth/92URuPmPjAioEpTqM cLUklMnSvxyTfC9CDHkK/VuTTpql32qUuhdU5wlpWRMr X-Google-Smtp-Source: ABdhPJw3/2n4UAZ4Q5VcqALztl1MZk6sW71Fthq1+FFB5IruwhYo0aDdbYqxJdw1Q6ecCO+voJXjkvCZHiw+0HT+uLQ= X-Received: by 2002:a05:6402:1ca8:: with SMTP id cz8mr30424047edb.55.1593897780609; Sat, 04 Jul 2020 14:23:00 -0700 (PDT) MIME-Version: 1.0 References: <71NYCQ.87F07ED5PFH2@gmail.com> In-Reply-To: From: Shawn Walker Date: Sat, 4 Jul 2020 14:22:50 -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 13:06, Westerbly Snaydley wrote= : > On Sat, Jul 4, 2020 at 14:48, 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 a= bout > >> lifetimes. If I try to use =E2=80=98x=E2=80=99 once the binding has = expired it > >> won=E2=80=99t let me and tells me why. Here it seems like Scopes sho= uld > >> 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 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). > > The bottom line is that in normal usage you will always never deal > > with pointers (or use most LLVM intrinsic functions), except when > > dealing with external C APIs (in which case you can immediately wrap > > in a checked type) or when implementing new language features. > > ...This is not to say this couldn't change or be added in, but it's > > my understanding that the behaviour is by design. > > > > Westerbly (radgeRayden) Snaydley. > > Slight correction: in this particular case it's fine to use plain > arrays, I meant it more that it's not recommended to use alloca, and if > you avoided that there would be no problem. The unique Array type > serves as the complementary solution for when you actually would use > dynamically allocated memory (like std::vector, I suppose). > Also, I think you need to hit reply all when responding to mailing list > emails, as your last one didn't show in the archives. Yes, that makes sense. I'm relying on the test code mostly as examples right now to try to make sense of Scopes' usage. That means I'm learning what works and what doesn't the hard way ;) As for the reply all mystery, that was because sourcehut refuses to process email to the list if your client sends text/html and text/plain instead of just dropping the text/html part (sigh). gmail's web client lets you explicitly use plain text email, so what's what I have it set to default to, but the mobile gmail clients (whether you use native app or web interface) don't let you choose :( --=20 Shawn Walker-Salas