From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 6A5CD7EE5B for ; Sun, 25 May 2014 16:56:59 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of ollie.frolovs.2012@my.bristol.ac.uk) identity=pra; client-ip=209.85.212.171; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ollie.frolovs.2012@my.bristol.ac.uk"; x-sender="ollie.frolovs.2012@my.bristol.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of ollie.frolovs.2012@my.bristol.ac.uk) identity=mailfrom; client-ip=209.85.212.171; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ollie.frolovs.2012@my.bristol.ac.uk"; x-sender="ollie.frolovs.2012@my.bristol.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wi0-f171.google.com) identity=helo; client-ip=209.85.212.171; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ollie.frolovs.2012@my.bristol.ac.uk"; x-sender="postmaster@mail-wi0-f171.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqIBANADglPRVdSrlGdsb2JhbABZg1mtB5VVAYEDFg4BAQEBBwsLCRIqgiUBAQEDARJcCwULCxgNISETAQUBChIGExIQiAwDCQgEAQinB2qpPAMKV4VDF4w8gSkBOTMHgyuBFQSEXgWTGoMzhS6GSoQBQYRpawGBCQ X-IPAS-Result: AqIBANADglPRVdSrlGdsb2JhbABZg1mtB5VVAYEDFg4BAQEBBwsLCRIqgiUBAQEDARJcCwULCxgNISETAQUBChIGExIQiAwDCQgEAQinB2qpPAMKV4VDF4w8gSkBOTMHgyuBFQSEXgWTGoMzhS6GSoQBQYRpawGBCQ X-IronPort-AV: E=Sophos;i="4.98,906,1392159600"; d="scan'208";a="63901866" Received: from mail-wi0-f171.google.com ([209.85.212.171]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 25 May 2014 16:56:58 +0200 Received: by mail-wi0-f171.google.com with SMTP id cc10so3015045wib.16 for ; Sun, 25 May 2014 07:56:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to; bh=Oaeo9cn42ZVknmKKbCPJiBIGLatthctcCXtMhqKuFYM=; b=JKISWm6bANwmtTuB/Wmu4+kbybgfROvgsfxB9s+9v70cLC6LQKuhKHoWC94f5B19XE TNlaiiM0GAQFtu9ruSv7BbPMTelg0fbG8YNwK577+cwpkaETZppvjLzUWneC54eYmNyY LVxzzTpKDtup/lvYM0nVYhGREoJCq41wC1PN8NE8zFU+HzuBMH2LazrTfX3226yl6T0S DZn2D5KFQeBYHo95WGGT6lG49CMkvKnI3vmkUEtfoTE/Y6J+sxUgKKARqLDG0bkCVTH8 P8cVtm4crKYBDx7TxvDbzYYDX5JkmF6lBOxKvK4vMZbj1k6n/zFz7GI44IAiO3UgLVE7 ZUcQ== X-Gm-Message-State: ALoCoQnImp7MbBaoWP7CXN5XB/g7eZpgrD5ovzAmCW77vuDAZmmFvgtdCrULAFzUmzg+kFXRkNOh X-Received: by 10.180.106.1 with SMTP id gq1mr19657983wib.45.1401029818032; Sun, 25 May 2014 07:56:58 -0700 (PDT) Received: from [192.168.0.12] ([2.220.224.146]) by mx.google.com with ESMTPSA id fw11sm18851054wic.4.2014.05.25.07.56.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 25 May 2014 07:56:57 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.2\)) From: Ollie Frolovs In-Reply-To: Date: Sun, 25 May 2014 15:56:55 +0100 Cc: Gabriel Kerneis , caml users Content-Transfer-Encoding: quoted-printable Message-Id: <5B604612-B40C-459F-9D5F-76B61ABE1B58@my.bristol.ac.uk> References: <52C51721-8564-472C-AA7A-2ABE66C4D809@my.bristol.ac.uk> <20140525105906.GB7716@kerneis.info> <15117B8E-A404-4911-AC68-769CDF00B22E@my.bristol.ac.uk> To: Gabriel Scherer X-Mailer: Apple Mail (2.1878.2) X-Validation-by: ollie.frolovs.2012@my.bristol.ac.uk Subject: Re: [Caml-list] Modules and record fields Aha. Now I understand what happens but I don=92t understand why. Specifical= ly, why would the compiler in Solarized.orange.r access the field =93r" in = the **current scope** of the value Solarized.orange, what use is this? In o= ther words why Solarized.orange.r is not equivalent to Solarized.(orange.r)= equivalent to Solarized.orange.(r), if that makes sense? There must be a g= ood reason. On 25 May 2014, at 14:57, Gabriel Scherer wrote: > The presence or absence of a warning is unrelated to whether it's a > local module or a separate file. Solarized.orange.r and > Solarized.(orange.r) are not equivalent. Solarized.orange.r means that > you access the field "r" (in the current scope) of the value > Solarized.orange. Solarized.(orange.r) opens Solarized locally for > both the resolution of the "orange" identifier and "r" field name. > Your new version is equivalent (Solarized's opening scope is even > wider). >=20 > The warning comes from the fact that since 4.01, OCaml can resolve a > field name not only by having its path given from the current scope > (eg. Solarized.r), but also by reasoning on the type of the record > value, even if the field name itself is not in scope. Accessing field > names that are not in scope is considered bad practice, hence the > warning (which is disabled by a few people that like this style). >=20 > On Sun, May 25, 2014 at 2:46 PM, Ollie Frolovs > wrote: >> It does, but I am rather disturbed by the compiler warning. I usually ai= m not to have them, particularly when I am new to the language, assuming th= at they at least hint at unsafe programming techniques. >>=20 >> Update: I=92ve put Solarized interface and definitions into separate fil= es (rather than having both as module Solarized =3D =85 in the main file) = and there is no warning anymore for some reason. Unless there is something = else I=92m doing differently without realising it. >>=20 >> I suppose that solves my problem. Thanks everybody! >>=20 >> solarize.mli: >>=20 >> type colour =3D {r:int; g:int; b:int} >> val base03 : colour >> val orange : colour >>=20 >> (* END *) >>=20 >> solarize.ml: >>=20 >> type colour =3D {r:int; g:int; b:int} >> let base03 =3D {r=3D0x00; g=3D0x2b; b=3D0x36} >> let orange =3D {r=3D0xcb; g=3D0x4b; b=3D0x16} >>=20 >> (* END *) >>=20 >> main.ml: >>=20 >> =85 >> Solarized.(Sdl.set_render_draw_color ren orange.r orange.g orange.b 0xff) >> =85 >> (* END *) >>=20 >>=20 >> On 25 May 2014, at 11:59, Gabriel Kerneis wrote: >>=20 >>> On Sun, May 25, 2014 at 11:30:20AM +0100, Ollie Frolovs wrote: >>>> let module S =3D Solarized in >>>> Sdl.set_render_draw_color ren S.orange.r S.orange.g S.orange.b 0xff >>>> (* etc etc *) >>>=20 >>> Doesn't this work with the latest version of the compiler? (with a >>> warning "r is not visible in the current scope, and will not be >>> selected if the type becomes unknown") >>>=20 >>> -- >>> Gabriel >>=20 >>=20 >> -- >> Caml-list mailing list. Subscription management and archives: >> https://sympa.inria.fr/sympa/arc/caml-list >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs