- Timestamp:
- Sep 16, 2024, 9:03:07 AM (2 months ago)
- Branches:
- master
- Children:
- e37d45e1
- Parents:
- 0bda8d7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/proposals/modules.md
r0bda8d7 reaeba79 192 192 At the linker level, an extra step is necessary to perform a transitive closure across module dependences, i.e., build a "using" graph to know what order to run the module constructors. 193 193 For example, the heap has to be initialized before any other code that uses it. 194 195 ============================================================================= 196 197 From: Andrew James Beach <ajbeach@uwaterloo.ca> 198 To: Peter Buhr <pabuhr@uwaterloo.ca> 199 Subject: Re: A Module Proposal 200 Date: Fri, 31 May 2024 20:32:49 +0000 201 202 Ada uses several constructs for what you described: 203 204 First the includes are handled by: 205 with MODULE_NAME; 206 207 (There is a separate "use" command that handles the name spacing part.) 208 209 In the header file (.ads) you declare: 210 package NAME is BODY end NAME; 211 (NAME is the possibly qualified name of this module, BODY all the contents of the module. Which I think is everything except the with/use commands and whatever comments you would like.) 212 213 In the source file (.adb) you declare: 214 package body NAME is BODY end NAME; 215 (Same rules on NAME and BODY.) 216 217 Of course I say same rules for BODY, but obviously it isn't quite the same. You have something like the declaration / definition divide C uses about what goes where. You do seem to have to repeat some information as well. 218 219 Anyways, I did some double checks, but mostly this is just me rattling off what I remember from earlier investigation of Ada. 220 221 Andrew 222 ________________________________ 223 From: Peter A. Buhr <pabuhr@uwaterloo.ca> 224 Sent: May 31, 2024 4:13 PM 225 To: Andrew James Beach <ajbeach@uwaterloo.ca> 226 Subject: Re: A Module Proposal 227 228 For the section on "file-links can be embedded in data creating a tree", I 229 don't know what that means. 230 231 Think of a file system like a database, where a table can have data and links to 232 other tables. For a program you might have. 233 234 for ( link to shared expression ) { link to shared for body } 235 236 In smalltalk, I believe they have this kind of structure. 237 238 class X { 239 link to some code in another file 240 code code code 241 link to some code in another file 242 } 243 244 Then we two ways you can use modules in a language: Visibility and 245 initialization. I did say a few things about the first, but nothing on the 246 second. 247 248 Agreed. 249 250 Is there any interaction between modules and local information hiding? None seem to be called out. 251 252 It was just an outline. I need to look at Ada packets to get more details. 253 254 Now you have an example where you declare a module syntax: 255 What section of code does this wrap? Does this go in a header, a source file? 256 Is the module also a namespace? 257 Does the using clause actually trigger #include? How does it interact with #include directives? 258 Looking at the constructor: is the module a (real) type? If so what properties does it have? 259 260 Let's see what Ada does with packages. It has to be VERY similar to what CFA 261 needs. 262 263 How does this effect organization across translation units? You say it would 264 put Mike's work into one translation unit, how does it do that and what is 265 the gain there? 266 267 module link-lists { 268 link-list stuff 269 } 270 module arrays { 271 array stuff 272 } 273 module strings { 274 string stuff 275 } 276 277 It is possible to import arrays and not other modules, so the compiler 278 selectively reads the above translation unit for the modules it is looking for 279 and does not have to parse modules it does not need. The code is nicely grouped 280 and named. 281 282 "At the linker level", does this mean we also have to rewrite/wrap the compiler? 283 284 The linker has a whole language that allows you to write complex instructions on 285 what it is suppose to. I don't know how powerful the link language is. 286 287 https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_chapter/ld_3.html 288 289 290 291 From: Andrew James Beach <ajbeach@uwaterloo.ca> 292 To: Peter Buhr <pabuhr@uwaterloo.ca> 293 Subject: Re: A Module Proposal 294 Date: Sun, 2 Jun 2024 19:53:56 +0000 295 296 OK, down the list: 297 298 > Why does CFA have include files? Why don't we use the Smalltalk for modules? 299 300 It feels like the IDE is just the surface level of something else. After all, some people already develop Cforall embedded in an IDE (I think, it looks like that is what they are doing when they screen share). Maybe I'm misreading the situation, but it feels like we are talking about the amount of non-code configuration and/or a compile-time vs. runtime divide. 301 302 > Think of a file system like a database, where a table can have data and links to other tables. For a program you might have. 303 304 Do you mean includes and other uses of file paths? 305 306 > In smalltalk, I believe they have this kind of structure. 307 308 What kind of Smalltalk are we talking about? (Old Smalltalk as OS or something like the relatively modern GNU Smalltalk?) 309 310 > Let's see what Ada does with packages. It has to be VERY similar to what CFA needs. 311 312 I will not go over the whole thing again but Ada seems to have for constructs for this: 313 with NAME; imports a qualified module. 314 use NAME; can be used to rename a bunch of qualified names. 315 package NAME is BODY end NAME; declares a module (package) interface. 316 package body NAME is BODY end NAME; provides the implementation for the above. 317 318 > It is possible to import arrays and not other modules, so the compiler selectively reads the above translation unit for the modules it is looking for and does not have to parse modules it does not need. The code is nicely grouped and named. 319 320 Can't we already do that by putting them in separate files? Also, how do we get away with parsing only part of a file? 321 322 Andrew 323 ________________________________ 324 From: Andrew James Beach <ajbeach@uwaterloo.ca> 325 Sent: May 31, 2024 2:57 PM 326 To: Peter Buhr <pabuhr@uwaterloo.ca> 327 Subject: A Module Proposal 328 329 I am working of folding the two sections of the proposal and I have some questions. 330 331 The paragraph on IDE passed languages. What is it for? C and Cforall are not that type of language and you never bring it up again as a comparison. 332 333 For the section on "file-links can be embedded in data creating a tree", I don't know what that means. For bit I thought you meant includes, but you talk about those separately. Maybe module names using with import statements. Could you go into more detail? 334 335 Then we two ways you can use modules in a language: Visibility and initialization. I did say a few things about the first, but nothing on the second. 336 337 Is there any interaction between modules and local information hiding? None seem to be called out. 338 339 Now you have an example where you declare a module syntax: 340 What section of code does this wrap? Does this go in a header, a source file? 341 Is the module also a namespace? 342 Does the using clause actually trigger #include? How does it interact with #include directives? 343 Looking at the constructor: is the module a (real) type? If so what properties does it have? 344 345 How does this effect organization across translation units? You say it would put Mike's work into one translation unit, how does it do that and what is the gain there? 346 347 "At the linker level", does this mean we also have to rewrite/wrap the compiler? 348 349 350 351 From: Michael Leslie Brooks <mlbrooks@uwaterloo.ca> 352 To: Peter Buhr <pabuhr@uwaterloo.ca>, 353 Andrew James Beach 354 <ajbeach@uwaterloo.ca>, 355 Fangren Yu <f37yu@uwaterloo.ca>, Jiada Liang 356 <j82liang@uwaterloo.ca> 357 Subject: Modules 358 Date: Wed, 26 Jun 2024 20:25:23 +0000 359 360 I wrote down some of what was said during our call with Bryan today... 361 362 Peter's modules' intro 363 364 fine - like cpp public-private 365 med - when bits of several sources mash into a translation unit 366 coarse - the translation unit 367 368 369 Bryan's remarks 370 371 Often a library will have 372 external headers - what others include 373 internal headers - what all the library's units need to know 374 375 A points to B B can never get outside the library opportunity for object 376 inlining 377 378 Problem with pimpl pattern is after you do it, the compiler can't see that this 379 is what you're doing, it only sees it's a another plain old object. If it 380 could benefit from a pragma-pimpl, be assured that the impl part can't leak 381 out, then it could inline the impl. 382 383 For a Friday discussion group, the team would be interested in an improvement 384 in what C++ can do. 385 386
Note: See TracChangeset
for help on using the changeset viewer.