> But either
> way, the Net module would not be a standard module, and so that
> Chapel code would only be compiled if the program said 'use Net;'.
Terminology check: It *would* be a standard module (forming part of the
standard library); it would not be an internal / automatically-used
module. Right?
> Chapel doesn't have anything like #ifdef, but the generic programming
> facility is very flexible and could support string comparison on
> config params that indicate the current platform. I believe that
> should work now, but havn't tried it. These are defined in ChapelBase.chpl
> line 1-123. You should be able to say something like (I'm intentionally
> ignoring details):
> proc mygetaddrinfo() {
> extern proc getaddrinfo();
> if CHPL_TARGET_PLATFORM == "cray" {
> // do something else
> } else {
> getaddrinfo()
> }
> }
Such a thing should work -- the primarily limitation of this capability
compared to an #ifdef is that it introduces a lexical scope, like any
other conditional, so can't be used to choose between two declarations,
e.g. We've discussed various ways of supporting that capability (because
it's a common thing to want) but none have been implemented yet. This is
part of the reason that I encourage doing this sort of switching at the C
rather than Chapel level.
> Since CHPL_TARGET_PLATFORM (and the other similar variables) are config param
> (ie compile-time) constants, the compiler is obligated to remove the branch
> of the if statement that does not apply. Now, of course CHPL_TARGET_PLATFORM
> has a variety of versions for Crays, so perhaps your strstr would be
> useful at compile time, like
>
> if CHPL_TARGET_PLATFORM.contains("cray")
In order for this to work as the equality does above, contains() would
have to be made into a 'param' (compile-time evaluatable) method (another
reason to handle this at the C level, potentially).
> but that's a bit of a separate issue, which you should feel free to
> put off for the moment.
I agree.
-Brad
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers