Author Topic: Apple's proposed addition of modules to C/C++  (Read 13034 times)

kyle

  • Newbie
  • *
  • Posts: 48
    • View Profile
Apple's proposed addition of modules to C/C++
« on: June 19, 2014, 02:27:42 AM »
I know this has been hashed over, but Apple made a serious proposal for modules for C.  I thought that it was fairly well thought out.

http://llvm.org/devmtg/2012-11/Gregor-Modules.pdf?=submit

I thought that there was something else to see, but this is what I find with Google...

From what I remember at the time, the C and C++ language committees are (or at least were) seriously considering this proposal.  It seems pretty well thought out. 

Obviously C2 does not need the backward compatible parts, which is a large part of it!  But, there may be something to be learned.  If you've already seen this, feel free to ignore this post :-)

Best,
Kyle

bas

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: Apple's proposed addition of modules to C/C++
« Reply #1 on: June 19, 2014, 08:04:02 AM »
Hi,

I've mentioned this here: http://www.c2lang.org/forum/index.php?topic=15.0

In the Clang codebase there are Modules (from 3.4 I think), but still Beta. The problem
IMHO is that adding this is nice, but severely limits the options. In C2 we get a lot more
mileage from this concept (like global checking of unused etc)

kyle

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Apple's proposed addition of modules to C/C++
« Reply #2 on: June 20, 2014, 09:22:15 PM »
I was not suggesting that C2 adopt the exact system proposed by Apple.  I thought it was an interesting read (as much as you can read slides) to see the issues that they wanted to tackle. 

C2 would not have any need for the backward-compatibility aspects of the Apple proposal.

Eiffel has some interesting ways of importing other modules too.  I will have to look back over the discussion to see if that was already referenced.

It is easy to fall into the trap of doing so much that the common case is painfully verbose (hello, Ada!). 

There are some very interesting things happening in the Javascript world.  Since Javascript has no module/package system of its own, all these methods rely on convention.  Some are quite interesting.  One thing I like is the use of namespaces being passed in to functions that create the module.

Imagine something like this (please excuse the pathetic syntax):

Code: [Select]
namespace libs {
  with mylogging from awesomelogging;
  with yourlogging from waycoollogging;
}


Then I can use libs.mylogging.XYZ.  I have created a package namespace local to my code on the fly.

I am not sure this is useful or makes any sense.  I need to think about it a bit more.  This kind of thing is used in Javascript.  C2 is static, not dynamic here, but I think much of the same thing could be done, if it was useful.

Best,
Kyle