Mon Nov 29, 2021 9:25 pm
Login Register Lost Password? Contact Us


Compiling ECL code without specifying it's Module name.

Comments and questions related to the Enterprise Control Language

Mon Apr 10, 2017 11:55 am Change Time Zone

Hello,

I have the following structure of files in my ECL repository.
ModuleName :- MyModule
Files within the Module:-
1. MyFile1
2. MyFile2

I am referencing MyFile1 within MyFile2. Since both these files belong to the same Module (folder within my ECL repository), I did not refer MyFile1 in MyFile2 like "MyModule.MyFile1". This approach results in error that MyFile1 could not be found.

Now when I import MyModule within MyFile2 and then call MyFile1 like "MyModule.MyFile1", then the ECL code in MyFile2 gets compiled.

Is it always necessary to Import the module name within files belonging to the same Module ?

Thanks and regards,
Akhilesh.
akhileshbadhri
 
Posts: 23
Joined: Thu Sep 22, 2016 12:15 pm

Tue Apr 11, 2017 12:48 pm Change Time Zone

Hi Akhilesh,

In short, yes!

All EXPORTed definitions need to be explicitly IMPORTed, even if they are in the same folder.

You can also use the $ shortcut when referencing EXPORTed definitions in the same folder:

Code: Select all
IMPORT $;
$.MyFile1;


Regards,

Bob
bforeman
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1005
Joined: Wed Jun 29, 2011 7:13 pm

Tue Apr 11, 2017 12:53 pm Change Time Zone

Thank you Bob.
But in our current ECL repository, I do find most of the files being referenced in other files, without having the parent folder name prefixed to them. Is there some configuration with some environments / ECL IDE that helps in referencing files without being prefixed with their folder name ?

Thanks and regards,
Akhilesh.
akhileshbadhri
 
Posts: 23
Joined: Thu Sep 22, 2016 12:15 pm

Tue Apr 11, 2017 5:19 pm Change Time Zone

You may be referring to a feature in the repository before HPCC went open source that allowed this, but the Default folder in Open Source repositories is no longer valid and you MUST EXPLICITLY IMPORT a folder if you want to reference anything EXPORTed.

There is also this:

Code: Select all
IMPORT * FROM <foldername>;

Which removes the need to reference the folder, but development has told us that this usage will soon be deprecated, so I do not recommend using it.

Bob
bforeman
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1005
Joined: Wed Jun 29, 2011 7:13 pm

Wed Apr 12, 2017 6:35 am Change Time Zone

Thanks a lot Bob. This information helped a lot.
akhileshbadhri
 
Posts: 23
Joined: Thu Sep 22, 2016 12:15 pm

Thu Sep 21, 2017 2:36 pm Change Time Zone

The compiler supports a "-legacy" parameter on the command line. When using the ECL IDE, this parameter can be added in the "Arguments" field under the "Compiler" tab of the "Preferences" dialog box.

This parameter forces the compiler to look for definitions in the same folder without the need to explicitly IMPORT and fully qualify them. This helps to run legacy code unmodified.
RoqScheer
 
Posts: 4
Joined: Thu Sep 21, 2017 2:23 pm

Fri Sep 22, 2017 2:01 pm Change Time Zone

RoqScheer,
The compiler supports a "-legacy" parameter
That -legacy switch is meant only to support allowing pre-Open Source, central ECL Repository code to continue to function with newer Open Source builds.

The move to Open Source happened 6.5 years ago. That -legacy feature was added to allow a gradual migration from the pre-Open Source IMPORT code requirements (much looser due to the assumption of the presence of a central ECL code Repository) to the new Open Source requirements (where explicit IMPORT and full qualification is always required because there is no central Repository).

Prior to going Open Source, the HPCC platform was primarily an internal LNRS tool. LNRS migration to the new Open Source style (no central Repository) is in progress, so you can expect that this "feature' will eventually be deprecated. IOW, this is NOT a "shortcut" that you should rely on always being there to allow you to not have to type a few extra characters.

For all new code on a non-central Repository system, you should write ECL that follows the Open Source rules. We have been teaching that style of coding in all our ECL classes since the first day we went Open Source. You should NOT be using that -legacy switch on any environment that doesn't still have a central ECL code Repository.

HTH,

Richard
rtaylor
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1604
Joined: Wed Oct 26, 2011 7:40 pm

Fri Sep 22, 2017 2:11 pm Change Time Zone

SALT versions as recent as 3.7.1 still depend on this compiler option, though.
RoqScheer
 
Posts: 4
Joined: Thu Sep 21, 2017 2:23 pm

Fri Sep 22, 2017 2:23 pm Change Time Zone

SALT versions as recent as 3.7.1 still depend on this compiler option, though.


For now :-) As Richard said, this too will probably be deprecated in the near future.

When I get ready to do any SALT work, I have a custom SALT configuration in the ECL IDE that uses the -legacy flag, for all other work, the -legacy flag is removed.

Regards,

Bob
bforeman
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1005
Joined: Wed Jun 29, 2011 7:13 pm


Return to ECL

Who is online

Users browsing this forum: No registered users and 1 guest