<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'><div style="text-align: left;">How does one return a constant array of unspecified size from a function?<br>You know, what might otherwise be a constant array in the interface, but I'd<br>rather hide it behind a function?<br><br><br>something like this, though I haven't found anything that compiles and runs:<br><br><br>PROCEDURE GetPathVariableNames(): REF ARRAY OF TEXT =<br> BEGIN<br> RETURN ARRAY OF TEXT {<br>(* not all of these presently have meaning but they are suggested synonyms *)<br>(* 0123456789012345 *)<br>(* 8*) "CM3_ROOT", (* root of source tree *)<br>(* 8*) "M3CONFIG",<br>(*10*) "CM3_CONFIG", (* new unimplemented synonym for M3CONFIG *)<br>(*11*) "CM3_INSTALL",<br>(*11*) "INSTALLROOT",<br>(*12*) "INSTALL_ROOT",<br>(*14*) "CM3_SOURCEROOT", (* new unimplemented synonym for CM3_ROOT *)<br>(*15*) "CM3_INSTALLROOT",<br>(*15*) "CM3_SOURCE_ROOT", (* new unimplemented synonym for CM3_ROOT *)<br>(*16*) "CM3_INSTALL_ROOT"<br>(* 0123456789012345 *)<br>};<br> END GetPathVariableNames;<br><br><br><br>in C I would write:<br><br><br>char** GetWhatever()<br>{<br> const static char* strings[] = { "abc", "def", 0 };<br> return strings;<br>}<br><br><br><br>or<br><br><br>char** GetWhatever(size_t* Count)<br>{<br> const static char* strings[] = { "abc", "def" };<br> *Count = sizeof(strings)/sizeof(strings[0]);<br> return strings;<br>}<br><br><br>The client doesn't have to know if it is constant or not.<br>It could be initialized at runtime, with a dynamic size, or not<br>I should not have to make a copy per call.<br><br><br> - Jay<br><br></div></body>
</html>