The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Reuse of header files

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Reuse of header files Posted: Nov 18, 2006 3:31 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Reuse of header files
Feed Title: Michael Lucas-Smith
Feed URL: http://www.michaellucassmith.com/site.atom
Feed Description: Smalltalk and my misinterpretations of life
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Michael Lucas-Smith

Advertisement

Well.. some more DLLCC stuff. It's pretty much impossible to re-use .h files as classes in Smalltalk. Why's that? Because you may have something like this in your header file:

#ifdef BLAH

#define FOO BLAH

#endif

In this scenario, initially BLAH won't be defined. But then when another header file includes your header file and defines BLAH to be "Baz" - now we have a new variant of our header file. It doesn't make sense for our header files class to record that result - the header file that included the result should record that result.

So, what does that mean for reuse? Well, it means it is an incomplete concept. It'll work most of the time, but not in cases like the above. So what do we do? Well - I think we borrow a page from the book of DLLCC again.

DLLCC defines a C Interface that has libraries and header files. DLLCC would parse the header files and includes and then ask the developer which bits from all of those header files you wanted to keep. This is a bit insane - I think we can do better here. Why don't we say that we'll keep everything in the header files you specified and keep anything in any other included header file that is referenced by our primary header files.

That way, if there's a definition you really need to use your library, you just promote it to your header files include list.

Okay, so if we're doing things this way - is it now possible to use CPP? .. no. CPP will flatten everything out and there's no guarantee you can find out where a definition came from from its output. So we're back to square one - although now we're only doing a regular c pre-processor in Smalltalk and we're using a bit of smarts to automatically figure out what definitions to install.

Vassili suggested to me that I might have to be able to parse the C expressions as well. I'm not entirely sure if that's true yet - it certainly would be down the path if we decided to do some of the more advanced ideas that have been floating around. But for now, I may get away with just using DLLCC... I guess I'll have to see if there's enough information in DLLCC to figure out which definitions are referenced from the primary definitions.

Like I said in the first of these articles - you have to let these ideas percolate a bit to identify what really needs to be done and how big the task actually is. I've got through a few different iterations now and as you can see we've chopped back from a grandiose new kind pre-processor to an almost stock run of the mill pre processor. The less the merrier.

Read: Reuse of header files

Topic: How many ways can Vista Suck? Previous Topic   Next Topic Topic: Down at the local Gamestop

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use