From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: William ML Leslie Newsgroups: gmane.lisp.guile.devel Subject: Re: Auto compile from many different languages that interoperates with guile Date: Fri, 8 Sep 2017 11:39:25 +1000 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1504834798 25033 195.159.176.226 (8 Sep 2017 01:39:58 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 8 Sep 2017 01:39:58 +0000 (UTC) Cc: guile-devel To: Stefan Israelsson Tampe Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Sep 08 03:39:40 2017 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dq8Gd-0005NN-Fq for guile-devel@m.gmane.org; Fri, 08 Sep 2017 03:39:35 +0200 Original-Received: from localhost ([::1]:42896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dq8Gk-0006SE-6f for guile-devel@m.gmane.org; Thu, 07 Sep 2017 21:39:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dq8Gb-0006Rb-EL for guile-devel@gnu.org; Thu, 07 Sep 2017 21:39:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dq8GW-00017n-Bj for guile-devel@gnu.org; Thu, 07 Sep 2017 21:39:33 -0400 Original-Received: from mail-vk0-x229.google.com ([2607:f8b0:400c:c05::229]:38524) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dq8GW-00016d-77 for guile-devel@gnu.org; Thu, 07 Sep 2017 21:39:28 -0400 Original-Received: by mail-vk0-x229.google.com with SMTP id x85so1879095vkx.5 for ; Thu, 07 Sep 2017 18:39:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0AL+Z5YZKLZIKTAxZZULomQHvUQVC1afhenPZvgwZC0=; b=dYRPx+iCBI0XW6cYquaZAU/HVxmQS8gygpPUluzKdALCe+qnzrOfelix64g1TiC4lX wQ/kA+nbwJqDVPacdN7oYSIOUgkYHSeujlkt7x3a6S0uuvL06xsIeo1DaN/aBc5XW91M Hq++a4S7jOOMvTeueIVy4XVOsLqZyo921JbZTwpsEHkC2IO7dwWlVu1BEtiK9skjf3oQ jF851eDeHvtWS9BI7FeJ/Ji0v4Av4La7321np3Y/k1ctdWPC9Igv9pgJkIXjo1gnk9eU 39ps2VUdPh0/ctvTmtUBEdkxhKYyYFi2S0feiYwht8o/ow32h/Jyo2Gh8CpQd0Co82mF 1frA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0AL+Z5YZKLZIKTAxZZULomQHvUQVC1afhenPZvgwZC0=; b=cazLdqv7XagAnrAUZHJOgyNhjtqRfJwaSLTUmJ4NH+qq4eNt7+MS8sYrIukyx4SsG7 Koqebmpu4OypIcGE0bdDLXGkU2eiVT9dXBAXt6xBbMAB3LCEdgWGx2K7f43iPWGYaYFB jbTITeO/0ID/R3/mI+GJl6TuHTaHLM9w7Mux3IUTqeScDIHUedYMBONC/2P6BtKYVq1K vociPgiozctV3h2OzZJBdnF7kTa09I9PIzSx0THXRe5+dHZ+oekp3QH5v11JYAobU4R5 sZ8qpsc+8LgXtOaNWqVhkdhGDu3b34al19WmJvUFAC8WwS0oMWo84CpKFrJsoRuDQszu 9+pg== X-Gm-Message-State: AHPjjUgWvP5gfJqr8/ZUvusSKtp4EVPd2zoGrHyUcx7xR8OkbGdyLJ0i aw9wjX5iPsQwYmegUvxUczGrWrnHPQ== X-Google-Smtp-Source: AOwi7QB9IQe4zX233swhGdQkufoRm0QDxfQbTJQURKM0dVCo3GMCgDXTfEhkS2iXsv0OlZecnoWf5yOjRkQqqHRRjSg= X-Received: by 10.31.107.205 with SMTP id k74mr769435vki.160.1504834766354; Thu, 07 Sep 2017 18:39:26 -0700 (PDT) Original-Received: by 10.176.90.142 with HTTP; Thu, 7 Sep 2017 18:39:25 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400c:c05::229 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19273 Archived-At: On 2 September 2017 at 06:45, Stefan Israelsson Tampe wrote: > form is either specified or current-language and what I propose is to add a > knob that enables another version of the default for from e.g. something > like the following. > > (define %extension-map '((("py" "python") python) ((("pl" "prolog") prolog) > (("scm") scheme))) > (define %use-extension-map #f) > (define (default-from-file file) > (define default (current-language)) > (if %use-extension-map > (let* ((ext (get-extension file)) > (lang (find-language ext %extension-map))) > (if lang lang default)))) > ... > I think that we already have variables that discovers the source files that > guile can compile and I don't think that we should get name clashes as long > as we use the prefix (languge prolog module) as a prefix for modules in > other languages than scheme. > > WDYT It's really nice that you are thinking about this. Thank you for suggesting one direction to move in. I think python's own mechanism for having different relationships between the module requested and where it is drawn from is quite elegant. In your solution you use the current language to favor a list of file extensions over others, but I think you will also may want to have different search paths per extension as well as different module search algorithms and compile-time module generation. Some big python modules find out the ideal implementation for your system and then replace themselves in the module list, for example, depending on whether certain FFI modules are available or what operating system we are running on. The mechanism for doing this in python is a list of ``importers``. Importers are tried in order and asked if they can provide the package with a certain name. If they can, they return a loader which can load that package. In a polyglot environment, it would be reasonable for each language to have its own importer in the shared importer list, and also have each language order its own importers first when that language is making the initial request. https://docs.python.org/3/library/importlib.html#module-importlib It is an open question in my mind as to how dynamic the module search system should be. At the extreme end you have languages like TCL which scare me a bit. Similarly python had some great potential with setuptools' ``require`` system to have multiple versions of a package installed and have the application specify which version to run but it was lacking just that last bit of tooling. Still, I think importers are a nice sweet spot at providing a cross-language module system. -- William Leslie Notice: Likely much of this email is, by the nature of copyright, covered under copyright law. You absolutely MAY reproduce any part of it in accordance with the copyright law of the nation you are reading this in. Any attempt to DENY YOU THOSE RIGHTS would be illegal without prior contractual agreement.