Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by mail-b.sr.ht (Postfix) with ESMTPS id E4F91FF114 for <~duangle/scopes@lists.sr.ht>; Sat, 4 Jul 2020 19:49:00 +0000 (UTC) Authentication-Results: mail-b.sr.ht; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UoY1sd0p Received: by mail-qk1-f195.google.com with SMTP id q198so31622320qka.2 for <~duangle/scopes@lists.sr.ht>; Sat, 04 Jul 2020 12:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HDueCF6CnFNrtuQZX0pJJFUUEfq2JvqY7sGFbyG5tJQ=; b=UoY1sd0pNVj8cug4np3RrM95xCyF4W5ZZVA7ANULi/SQImQQNnEhF5x2w33CzE3AOW f32p/kZSIPWrJQJsGw+T0qDH8bR080sHvaxL7a45rU+nkRDXzcxJXRdo09ZB3zweej1V xLl0UYSRMn/IUzXIfwkP+OmntgpL57BN5jNmLW1eSJEAVs3XhlKFEXyI3Oj+DF7wfyZF BXVCFRMw07gts4QtLXXIrw8oWTeZDRXfGG/XKBGiVnbxBFYmuo+zk2h82aNBozfQw75A kYPxEs7tlmfKSdvW7KWh7VjJBNFoqNBrDG54giQbJgU82+7yoMZ4qnGTrZqBDdIvD8UN 4pSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HDueCF6CnFNrtuQZX0pJJFUUEfq2JvqY7sGFbyG5tJQ=; b=ahFhcYNZmiRuPKrrcrV8YDwyzORziOj/QnoGkS30gcgQ+inzhKqJs0JPn0axSQsKyJ cT+QAPedEptQ2pJJdbidWqqJoooeasfiIJNl8HCpjLkk3X0H8TP5XlgDI7XJXvOkgib1 pq2QpYSDmTK4lfxAxBRpq64vzu4eU3rXVkGwdZMl21E0JraJgiU4x9XedC0Qi5BM7GbO nvXGwdz+JiyZCnA4IrIucxSWDrr8wHQgWge773svu62L9BLAW0b5dkohibI1S7zK8AQJ KbxxB9B9zW20E295G4A5ZpNd0+AU1A9hOUArnEQywqqCP2NuUcR9Gifk2zI35CCmWS93 OaPA== X-Gm-Message-State: AOAM533F/lhsIFpWoZD7Ayt+iZ/Et4u2Leg196LBbr2XYnTYSF29Z9p3 lcjWNQtg5S57zwwgTffc1Sw= X-Google-Smtp-Source: ABdhPJwd/26f7oRUGHzTdeRbNDS88zBz7D+FCVR2a9YO4OrROpmqsNeRjyVllV1kVWheyYWkOZ97/g== X-Received: by 2002:a37:51c6:: with SMTP id f189mr41073800qkb.339.1593892140425; Sat, 04 Jul 2020 12:49:00 -0700 (PDT) Received: from pop-os ([2804:d59:26a4:c100:d8ad:591f:cc03:16f]) by smtp.gmail.com with ESMTPSA id 188sm13535358qkf.50.2020.07.04.12.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 12:49:00 -0700 (PDT) Date: Sat, 04 Jul 2020 14:48:43 -0500 From: Westerbly Snaydley Subject: Re: unexpected behavior with arrays? To: Shawn Walker Cc: ~duangle/scopes@lists.sr.ht Message-Id: <71NYCQ.87F07ED5PFH2@gmail.com> In-Reply-To: References: X-Mailer: geary/3.36.1 MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: quoted-printable On Sat, Jul 4, 2020 at 12:34, Shawn Walker =20 wrote: > I guess I=92m spoiled by the rust compiler=92s reasoning about=20 > lifetimes. If I try to use =91x=92 once the binding has expired it=20 > won=92t let me and tells me why. Here it seems like Scopes should=20 > know the lifetime of the storage and then could prevent or warn about=20 > further use. Scopes' borrow checker is opt-in, and the core is designed such that=20 lower level constructs / APIs are not checked. The higher level APIs on=20 the other hand are built on top of those but with security added in. In=20 this particular example, it's usually recommended to use the Array=20 (from Array.sc) data-type instead, which is both bounds and lifetime=20 checked. Similarly alloca, malloc shouldn't be used directly (ie. use=20 `local` with a unique type, or a Box for heap). The bottom line is that in normal usage you will always never deal with=20 pointers (or use most LLVM intrinsic functions), except when dealing=20 with external C APIs (in which case you can immediately wrap in a=20 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=20 understanding that the behaviour is by design. Westerbly (radgeRayden) Snaydley.