From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Raeburn Newsgroups: gmane.lisp.guile.user Subject: Re: Now that SCM type is a union... Date: Sat, 13 Aug 2011 18:00:39 -0400 Message-ID: <0F01A791-AEE9-49D5-BA9D-762C7DCF879B@raeburn.org> References: <20110812124436.GA2223@ccellier.rd.securactive.lan> <74643390-9111-4086-B315-1D2F847A514B@raeburn.org> <87y5yxfqk4.fsf@pobox.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1313272854 18260 80.91.229.12 (13 Aug 2011 22:00:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 13 Aug 2011 22:00:54 +0000 (UTC) Cc: guile-user@gnu.org To: Andy Wingo Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Aug 14 00:00:49 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QsMG8-0000ad-Cu for guile-user@m.gmane.org; Sun, 14 Aug 2011 00:00:48 +0200 Original-Received: from localhost ([::1]:57695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsMG7-0002rh-Mb for guile-user@m.gmane.org; Sat, 13 Aug 2011 18:00:47 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:46654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsMG3-0002rU-Mr for guile-user@gnu.org; Sat, 13 Aug 2011 18:00:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QsMG2-00008R-JP for guile-user@gnu.org; Sat, 13 Aug 2011 18:00:43 -0400 Original-Received: from mail-qw0-f41.google.com ([209.85.216.41]:48450) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsMG2-00008M-EW for guile-user@gnu.org; Sat, 13 Aug 2011 18:00:42 -0400 Original-Received: by qwa26 with SMTP id 26so2572567qwa.0 for ; Sat, 13 Aug 2011 15:00:41 -0700 (PDT) Original-Received: by 10.224.203.130 with SMTP id fi2mr1564940qab.329.1313272841616; Sat, 13 Aug 2011 15:00:41 -0700 (PDT) Original-Received: from [10.0.0.158] (c-24-128-48-142.hsd1.ma.comcast.net [24.128.48.142]) by mx.google.com with ESMTPS id d12sm3171401qcd.14.2011.08.13.15.00.40 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 13 Aug 2011 15:00:40 -0700 (PDT) In-Reply-To: <87y5yxfqk4.fsf@pobox.com> X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.216.41 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8710 Archived-At: On Aug 13, 2011, at 08:23, Andy Wingo wrote: > I only have a draft copy of C99, from 7 September 2007, but it does > permit constant expressions to appear outside function bodies. How > could that happen except for in initializers? I do see the language = in > the GCC docs though; it's confusing. I was under the impression that > they would be constant expressions, but perhaps I was mistaken. It is confusing. There's an example in the final spec which I think = indicates what's happening: int *p =3D (int []){2, 4}; // definition at file scope, outside any fn The compound literal produces an anonymous object (with static storage = duration, in this case) of type "int[2]"; in this context, its = initialization elements have to be constants. Through the standard = conversion of array to pointer-to-element, the value of this expression = becomes an "int *" which is used to initialize p (allowed because the = object has static storage duration and thus its address is a constant). When array/pointer conversions aren't involved, you might assume you = could just initialize a variable statically, but since the compound = literal creates an object, an lvalue, it's more like saying: static int anon =3D 3; // "anonymous" obj with constant initializer int x =3D anon; // not allowed in C99 You could make "anon" const, but it wouldn't change anything, under C99 = rules. Note, too, that the unnamed object created doesn't need to be = "const" -- changing p[0] above is perfectly valid. Though if you use = const in the type, then the compiler is permitted to combine identical = values and store only one copy. Also: * We should expect some Guile applications to be in C++. What versions = of the C++ spec should Guile support? * Shouldn't there be testing to catch this? (C89 mode, C99 mode, = different C++ specs, enabling various compiler warnings -- for whatever = compiler is in use -- and make them fatal, any interesting ways one = might want to use libguile in an application that might stress = compatibility issues.) I mean automated testing, not just Cedric. :-) > I will take a look at this issue soonish, but your help (and Cedric's) > in debugging it is most appreciated :) I would love to keep the union > as the "normal" SCM definition, but that might not be possible. Regardless of the validity, there are popular compilers out there now = which do not support this, when used in modes people may need or want to = use. The installed headers need to adhere to higher standards in terms = of portability problems and warnings than the library source, where we = can dictate some of the compiler options. Ken=