From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id YL32NiPlCmZERAEAe85BDQ:P1 (envelope-from ) for ; Mon, 01 Apr 2024 18:47:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id YL32NiPlCmZERAEAe85BDQ (envelope-from ) for ; Mon, 01 Apr 2024 18:47:31 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=l6qdm8Sv; dkim=pass header.d=johnnyrichard.com header.s=key1 header.b=u9zCzI+A; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; dmarc=pass (policy=quarantine) header.from=johnnyrichard.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1711990051; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-unsubscribe:list-subscribe: list-post:dkim-signature; bh=sdglgRuoRqfq0+5hEZztPENr0D9Q/YGIP1PU18mdV0U=; b=uA+2uyVLJAfszGmcs4LZHpseh887TlAu+3LK+M4b51/RyrZPKq0bH9oNvNbIQtx6Kib+Rv iPqjJa3TAPyc+TedkMC5kli+AauBjz0OIcsk8cScRz1O0oYQxyYgo439cLj0vA6+3iLez2 v+cSRdqV34vHvNzk3PCsTaQC1CeMuWBfsBstCcy/DNDhphzORNHeIr94eNYVls2ehgAJJD B5d2y10gEC/kPK9urIaG9BSwhjSnME3zP12l2jnT1PzoGBm+BkF6uxuwuScg9Gy0AbXGzE xlWfTcmoYkB6TA+89Cph3UKqTkhHfgegj07QRutbbbt4p2GtTG0GXaeNZiugJA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=l6qdm8Sv; dkim=pass header.d=johnnyrichard.com header.s=key1 header.b=u9zCzI+A; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; dmarc=pass (policy=quarantine) header.from=johnnyrichard.com ARC-Seal: i=1; s=key1; d=johnnyrichard.com; t=1711990051; a=rsa-sha256; cv=none; b=r5B+FYqhKA6NPwBe5yqFPA+goWPnFQxbltZOJuwbdJCvdCl1WTT2WWy22ZtCz2esMwPztd OdgE/nHfvcuZ8FTa6Ghjxgm5Hi8VFdNeTlGyhcTvslSOeeCCuMcfu1dsRZYJg+OULL+cvG 3raQO1dL5WZMLRZDRMX9+ESTunHv4vuSaftQbX7xmewDv4O8nP6K8/QIvaGAGWUFwciXrq QbSZq88BFdwlPNFPObCWEs/RDv6rnZ/Oajxtflzc11HkL5st690dWqe4xR4khQdWitaRhV LVytXrl51SF1WYaR+ykjy23lOza2K3HaH7ixY1no5O6cEpugsa/28RAxMRrJSg== Received: from mail-a.sr.ht (mail-a.sr.ht [46.23.81.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CC968671F5 for ; Mon, 01 Apr 2024 18:47:27 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=HHC1WoGxMna3LbJdCmT/m8WhArmmxFA2M0KcC8oKCE0=; c=simple/simple; d=lists.sr.ht; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1711990047; v=1; b=l6qdm8SvsPf5Zo9nvRaBHqfM92T5CPhSNbIjpBKqtVEe8WYgPIRkFysNz/4aRQxnd4f7D1Oo 2g67+MoQLzF2lIYRrYKHVldL+0TRS0ZPJaweOGjh+mJMD1RfIxo7wuNP6pYwpe/kZL+BeBWBgS1 cGRkW5FWX1VPR57wlEhC0gKrZDt5j+RsPm3qMdIYw0Q8St+YVWSKXL7g746P7lmF3hmKNNgRZNM eMXp7IlY31jugeFBsK9tiWyhLr27KJssU+xEfTldKrgR9zLMGGuZQpRj9wAkIWoRWfNdXn9iR5L ALuqghLeqKD2g4tAOdRDaNHBxlRHecZejWn1jRkNduUuQ== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id E6CD320201 for ; Mon, 1 Apr 2024 16:47:26 +0000 (UTC) Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [IPv6:2001:41d0:1004:224b::b5]) by mail-a.sr.ht (Postfix) with ESMTPS id 38C9E201FD for <~johnnyrichard/olang-devel@lists.sr.ht>; Mon, 1 Apr 2024 16:47:26 +0000 (UTC) Date: Mon, 1 Apr 2024 19:48:24 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1711990044; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sdglgRuoRqfq0+5hEZztPENr0D9Q/YGIP1PU18mdV0U=; b=u9zCzI+AEgFuVwVg4ErNudoDM3X9VLdMi49tP4VMHVRGy2R+wHcurHw2l56hfUcpzqKwzY toBEAxv1LRywjXTj6FxNx6XDMRjcWNeRsk2xODExiLBVjyyD6NbQcCpzfdD2bNTsNP/hjA 35/Kdv3+THs6wQ6G6SE5D0k0ElBa+U+7D9QVfbgqX5kf/0Zz5bFDGkk/SGqSt+6qqd+5fz TlkgGapkuID20XUg5MIUgQjdoZFUhp+3mbVHS2HV1GUuNEr0oUuG9dbruHRpBKhXROPPiD ce5B1HEau7KBTBxN1fTwwSNlqm0j3hCjWF+fL8rTKD1yVcTCm+LVYYeZnTfmjg== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Johnny Richard To: Carlos Maniero Cc: ~johnnyrichard/olang-devel@lists.sr.ht Subject: Re: [PATCH olang v1 2/2] docs: spec: add variables and constants specification Message-ID: References: <20240327032128.406911-1-carlos@maniero.me> <20240327032128.406911-3-carlos@maniero.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Unsubscribe: List-Subscribe: List-Archive: Archived-At: List-Post: List-ID: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel.lists.sr.ht> Sender: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel@lists.sr.ht> X-Migadu-Country: NL X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: CC968671F5 X-Migadu-Scanner: mx11.migadu.com X-Migadu-Spam-Score: -10.11 X-Spam-Score: -10.11 X-TUID: 9AC3K6bHUfk2 On Thu, Mar 28, 2024 at 11:11:38AM -0300, Carlos Maniero wrote: > On Wed Mar 27, 2024 at 6:37 PM -03, Johnny Richard wrote: > > On Wed, Mar 27, 2024 at 12:21:28AM -0300, Carlos Maniero wrote: > > > This commit introduces the specification for variables and constants. A > > > valid program under this specification is as follows: > > > > > > var x: u32 = 1 > > > > Since this patch adds support to assignments, lets also add support to > > all assignment operators like "-=" "+=" "<<=" and so on. > > > > > const y: u32 = 2 > > > > This patch lacks support to the following valid assignment expression > > (which I think adds flexibility to the language): > > > > var x: u32 = a = b = c = 1 > > var y: u32 > > y = a = b = c = 1 > > > > > - ::= > > > + ::= | | | > > > > nitpick: maybe _external-declaration_ sounds better since definitions are > > not statements? > > What do you think about *file-declarations* a file declaration? Does not > mean that it is external. At least while we try to define a file. hmm.. It sounds weird mention file. Feels like you are going to declare files... But I don't want to spend a lot of time on it. It was a nitpick... If you think *external-declaration* is not good enough we can keep *global-statement* (no blocking here). > > > + > > > +(* Variables *) > > > + ::= 'var' ':' ? > > > + ::= 'const' ':' > > > > We don't need to define twice the variable-definition for "var" and > > "const", let's combine both in a single rule. > > I don't know if you noticed, but variables has an optional assignment > while const has required assignment. Sure, I noticed. I took a look to how C solve this problem and seems like it allows defining a const without assignment (I don't know why...). I would do the same to keep the gramma simple. And if we really want to advice the developer about weird declaration, we could warning message during semantics checking phase. > > + ::= ':' ( )? > > This is invalid for const unless we want to allow unassigned constants. > It also can be interpreted as a semantic error, in that case I believe > the spec should not check for semantics. Let's handle it during semantics analysis.