caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Nils Becker" <becker.nils@gmx.net>
To: caml-list@inria.fr
Subject: [Caml-list]
Date: Fri, 21 Aug 2015 14:28:11 +0200	[thread overview]
Message-ID: <trinity-b1c5b10b-d8b3-4d36-8744-7750464c3977-1440160091101@3capp-gmx-bs47> (raw)
In-Reply-To: <20150821100011.4BF127F0D7@sympa.inria.fr>

hi, 


> > - Local opens are somewhat of an anti-pattern in OCaml, because they're
> > usually used in places where you have the same names defined in
> > multiple modules:
> 
> While this is certainly a very popular use case in particular when
> dealing with operators, I find myself using the local 'let open' form
> very often in other contexts. In fact, I don't ever seem to find myself
> using it for redefining identifiers. 

as another data point: i do the same. a typical function definition would be

let process_list list = 
  let open List in
  list 
  |> map fun1
  |> map2 fun2 another_list
  |> iter fun3

basically whenever i can save more than 3 List. qualifiers in the body of a short function where the context is clear, i will do it. i don't see where the problem is with this usage; the standard modules i open are not subject to a lot of change. i think the readability gain is worth it.

>> (** Rotation on the vect(x,y) plane with an angle t
>> precondition: x and y are orthonormal *)
>> let rotation (x,y) t v = let open V in
>> v
>> + R.( ( cos t - 1. ) * (v|*|x) - sin t * (v|*|y) ) * x
>> + R.( sin t * (v|*|x) + ( cos t - 1. ) * (v|*|y) ) * y

+1. this is the kind of code that i would like to write as readable as possible with a short local open. it's basically a remedy for not having operator overloading.

> - In the absence of Modular Implicits, as Petter mentioned, it would be
> nice to have the warnings/potential errors only generated when the same
> names have the same types. In case of different types with the same name,
> the type system should take care of any issues. 

this sounds like an elegant way to allow freedom of shadowing while keeping bugs under control.

another maybe trivial point: there are larger libraries that are designed to be opened destructively (Batteries etc); if the warning policy is changed in the same way for short and long opens, it should remain possible to do open! Batteries without a warning.

       reply	other threads:[~2015-08-21 12:28 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20150821100011.4BF127F0D7@sympa.inria.fr>
2015-08-21 12:28 ` Nils Becker [this message]
2022-02-19 17:25 [Caml-list] Latif A
  -- strict thread matches above, loose matches on Subject: below --
2021-10-11  7:57 [Caml-list] Vasilis Goumas
2021-09-29 15:47 [Caml-list] Vasilis Goumas
2021-04-19 13:49 [Caml-list] Aaron Gray
2021-04-11 13:58 [Caml-list] Ulugbek Abdullaev
2021-04-07 11:50 [Caml-list] Fabien / maufred
2021-01-24 16:20 [Caml-list] Latif A
2019-11-11  1:58 [Caml-list] Alexandre Macedo
2019-04-26 19:04 [Caml-list] Wei Wen Goh
2016-12-29 18:00 [Caml-list] Matthew Tovbin
2016-05-31  6:28 [Caml-list] Seshachalam M
2016-05-12 15:42 [Caml-list] Hongbo Zhang (BLOOMBERG/ 731 LEX)
2015-12-31 20:29 [Caml-list] Adil Hafeez
2015-10-09  6:33 [Caml-list] Gergely Szilvasy
2015-03-09 14:44 [Caml-list] Secret
2014-12-16 23:43 [Caml-list] André Luiz Moura
2014-12-16  7:48 [Caml-list] Sergey Abramyan
2014-07-04 10:35 [Caml-list] freetolearn 2013
2013-11-05 16:14 [Caml-list] Zhi Han
2013-09-25 17:56 [Caml-list] Dylan Sanders
2013-08-23 12:26 [Caml-list] Alexey Rodriguez
2013-08-23 12:56 ` [Caml-list] Robert Jakob
2011-12-07 21:19 [Caml-list] Joaquin Cuenca Abela
2011-09-14 19:45 [Caml-list] ds.caml
2011-09-14 19:00 [Caml-list] ds.caml
2011-09-12  5:50 [Caml-list] arupkumar.das
2011-08-20 16:05 [Caml-list] Jeff Massung
2011-06-28 17:09 [Caml-list] Agnius Vasiliauskas
2011-05-29 10:45 [Caml-list] ds.caml
2011-04-05  0:04 [Caml-list] Ãßõ¸ÞÀÏ »õ·Î¿î
2011-01-03 21:57 [Caml-list] Fabien / maufred
2004-01-03  6:52 [Caml-list] (±¤°í)¡Ú¡ÙÀÜ¿©Çѵµ´ëÃâ!!ÀÌÁ¨¹Ï°íÇϼ¼¿©!! ÇÑÁ¤¹Î
2004-01-03  5:16 [Caml-list] Àú¿Í ¾ËÄá´ÞÄáÇÑ ¾ê±â¸¦ ÇØ¿©! can2u
2004-01-03  4:03 [Caml-list] [±¤°í] ½´ÆÛ ÆÄ¿ö Æä´Ï½º ¸¸µé±â @ Àڽۨ
2004-01-03  1:36 [Caml-list] (±¤°í)¢Â´ëÃâ!! ÀüÈ­·Î ½ºÇÇµå ´ëÃâ Çص帳´Ï´Ù(ÃÖÀú%) ±è´ë¸®
2004-01-02 22:30 [Caml-list] (±¤°í)ÄÄÇ»Å͸¸ ÄÑ ³õÀ¸¸é µ·ÀÌ µÈ´Ù´Âµ¥ ÁÁÀºÁ¤º¸ Àü´ÞÀÚ
2004-01-02 21:02 [Caml-list] ÁøÁ¤ÇÑ ¸®¾óÄ«Áö³ëÀÇ ¼¼°è·Î ÃÊ´ëÇÕ´Ï´Ù!!! kim
2004-01-02 20:53 [Caml-list] Àý´ë ¼ºÀθ¸ Ŭ¸¯ Çϼ¼¿ä^^ kfskdsdfsdfsdf
2004-01-02 20:45 kfskdsdfsdfsdf
2004-01-02 18:08 [Caml-list] ÔÆÄÏÖ®Âà ÔÆÄÏÀö½­»¢ÌøÏ¿¹ú¼ÊÂÃÐÐÉç
2004-01-02 17:04 [Caml-list] È«Çò¾­¼ÃÔö³¤ÂÊ×î¿ìµÄ¹ú¼ÒÖ®Ò»! Ó¡¶È
2004-01-02 17:04 [Caml-list] ¿ªÍØÓ¡¶ÈÊг¡ Ó¡¶È
2004-01-02 16:38 [Caml-list] ÎÒÃÇ·ÅÆúÏòÈÕË÷ÅâÊÇÔÚÆäÉî¿Ì·´Ê¡µÄ»ù´¡ÉÏ£¬Ëû²»·´Ê¡£¬ÎÒÃǾÍÓÐȨË÷Åâ cameco
2004-01-02  8:51 [Caml-list] (±¤°í)ÄÄÇ»Å͸¸ ÄÑ ³õÀ¸¸é µ·ÀÌ µÈ´Ù´Âµ¥ ÁÁÀºÁ¤º¸ Àü´ÞÀÚ
2004-01-02  8:50 ÁÁÀºÁ¤º¸ Àü´ÞÀÚ
2004-01-02  8:29 [Caml-list] ¸¶ÄÉÆà ÇÁ·Î±×·¥ ¹«·á ´Ù¿î·Îµå! camlliou
2004-01-02  2:32 [Caml-list] (±¤°í)¿¬Ã¼,´ëÃâ °ÆÁ¤ ³¡!Áï½Ã ÇØ°áÇØ µå¸³´Ï´Ù!@ ºô·Áµå¸²
2004-01-01 15:47 [Caml-list] (±¤°í)ÇÞ¸êÄ¡,±¹³»»êÁãÆ÷, »êÁö ¿Õµµ¸Å°¡°Ý »êÁö Àۼ۾ȳ» @ I³²ÇؾȸêÄ¡9
2003-10-09 13:27 [Caml-list] ¾È³çÇϼ¼¿ä^^ ±è¹ÎÁ¤
2003-08-20  2:00 [Caml-list] °í°´´ÔÀÌ ¿äûÇϽŠ½Å¿ëÆò°¡¼­ ÀÔ´Ï´Ù ±è¾Æ¿µ
2003-06-21 17:58 [Caml-list] ½Å¿ë È®ÀÎÇϼ¼¿ä ±è¼ö¿µ
2003-06-21 17:58 ±è¼ö¿µ
2003-06-11 15:05 ±è¼ö¿µ
2003-06-11 15:05 ±è¼ö¿µ
2003-06-11 11:49 [Caml-list] ÆóÒµ¼Ò԰ȫиİ棬»¶Ó­·ÃÎÊ£¡ bepark
2003-06-07 19:43 [Caml-list] [Á¤º¸] °Ç°­Á¤º¸ÀÔ´Ï´Ù °Ç°­ÁöÅ´ÀÌ
2003-06-05 21:23 [Caml-list] ´ç½ÅÀÇ ½Å¿ëÆò°¡ ÀÔ´Ï´Ù ÇѼҿµ
2003-06-05 21:23 ÇѼҿµ
2003-06-03 17:38 [Caml-list] »çÀ̹ö ¼ö»ç´ëÀÔ´Ï´Ù ÇѼҿµ
2003-06-03 17:38 ÇѼҿµ
2003-05-01  8:40 [Caml-list] ÄãÒªµÄÈí¼þ£¬ÎÒ°ïÄãÕÒµ½ÁË£¬¿´¿´ÊDz»ÊÇÄãÒª°¡£º£© uxltiszukx@bea.com
2001-08-03 14:39 [Caml-list] == Willem Duminy
2001-08-03 14:52 ` Sven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=trinity-b1c5b10b-d8b3-4d36-8744-7750464c3977-1440160091101@3capp-gmx-bs47 \
    --to=becker.nils@gmx.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).