Tue Sep 22, 2020 2:04 pm
Login Register Lost Password? Contact Us


Newbe - getting to grips with compiler errors.

Comments and questions related to the Enterprise Control Language

Tue Oct 04, 2011 6:48 pm Change Time Zone

Hi,

I've been working my way though the example ECL program in 'HPCC data Tutorial' and though I get that working, any of my own work is stymied though lack of documentation of compiler errors.

e.g. The following code snippet

EXPORT With_index := DATASET ('~thor::Genesis::C2',{Layout_Verse,UNSIGNED8 fpos {virtual(fileposition)}},THOR);

generates error:

Warning: Definition program cannot define a public symbol with_index (24, 1), 2380,

And I cannot find a way round it. (This needs to be exported so the roxie fetch definition can use it.)
Other posts talk of errors being held in files ecl/hql/hqlerrors.hpp
I should not have to download open source to get a list of errors, which, I expect, wont explain the error.

So 1. Can someone please help with this particular error and
2. Tell me where error/warning messages are documented so I don't have to pester the forum every 2 minutes.

Yours

Allan
Allan
 
Posts: 430
Joined: Sat Oct 01, 2011 7:26 pm

Wed Oct 05, 2011 6:17 am Change Time Zone

The error message is trying to tell you that the name of the exported symbol has to match the name of the ecl file - I agree it could have been better worded.

On a more general point, I agree that we need documentation with a paragraph or so expanding on the possible causes and fixes for each compiler error - I'll make sure the documentation team get to see this message.
richardkchapman
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 110
Joined: Fri Jun 17, 2011 8:59 am

Wed Oct 05, 2011 8:17 am Change Time Zone

I've reworded the error message, so now it will say

Name of exported symbol 'With_index' does not match the expected name 'program'

Hopefully that would have been clearer.
ghalliday
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 196
Joined: Wed May 18, 2011 9:48 am

Wed Oct 05, 2011 9:41 am Change Time Zone

Thanks for these prompt reply's and actions it would seem - Wow!

I have not got to grips with what definitions must tie up with a filename. (I come from a c++ background)

My original question was a simplification of my actual code (It would be nice if attachments could be put with a message, if someone could pass that suggestion on, its preferable to code inserts as they break up the flow of text and it allows spreadsheets etc to be passed around.)
A larger snippet is:

Code: Select all
EXPORT Program := DATASET ('~thor::Genesis::C2',{Layout_Verse,UNSIGNED8 fpos {virtual(fileposition)}},THOR);

EXPORT Index_By_Chapter :=
    INDEX(Program,{Chapter,fpos},'~thor::Genesis::VerseByChapterINDEX');

BUILDINDEX(Index_By_Chapter,OVERWRITE);

This 2nd definition cannot have the same name?
From what I see one will end up with hundreds of small files in one project, that can't be true?

And with this refactored code I now get errors:
Code: Select all
Error:    WHEN must be used to associated an action with a definition (24, 1), 2325,
Error:    Definition program has a trailing public definition index_by_chapter (26, 1), 2380,


Yours

Allan
Allan
 
Posts: 430
Joined: Sat Oct 01, 2011 7:26 pm

Wed Oct 05, 2011 12:16 pm Change Time Zone

The idea is that each source file exports a single symbol.

However you can export a MODULE (think of it a bit like a C++ class/namespace), which means that you can publish a symbol with a structured type.

What you could do in this instance is something like:

Code: Select all
EXPORT Program := MODULE

    EXPORT InputDatset := DATASET ('~thor::Genesis::C2',{Layout_Verse,UNSIGNED8 fpos {virtual(fileposition)}},THOR);

    EXPORT Index_By_Chapter :=
        INDEX(Program,{Chapter,fpos},'~thor::Genesis::VerseByChapterINDEX');

    EXPORT BuildGenesis := BUILDINDEX(Index_By_Chapter,OVERWRITE);

END;


Historically we have tended to separate definitions from the queries that use them since the definitions can be reused. (In this case the file above might be called Genesis or bible), and another file could contain

Code: Select all
IMPORT Program;
Program.BuildGenesis;


Instead of using a separate file to contain the query you can include a main Attribute in you module:

Code: Select all
    EXPORT Main := BuildGenesis;


When you submit that file that defines a module as a query, eclcc will check to see if it has an attibute called main. If it has that is used to build the query.

Note, there isn't much difference between definitions with or without parameters in ecl, so the c++ side of you may prefer to to say.

Code: Select all
    EXPORT BuildGenesis() := BUILDINDEX(Index_By_Chapter,OVERWRITE);
    EXPORT Main() := BuildGenesis();


That will work equally well.
ghalliday
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 196
Joined: Wed May 18, 2011 9:48 am

Wed Oct 05, 2011 4:17 pm Change Time Zone

Thanks ghalliday,

I had tried using the MODULE construct using it as a namespace. Then referring to items as modulename.item (and variations thereof) to no avail.

I will now beaver away till the next brick wall (5 minutes I expect)

Yours Gratefully

Allan
Allan
 
Posts: 430
Joined: Sat Oct 01, 2011 7:26 pm

Thu Oct 06, 2011 11:43 am Change Time Zone

Alan,

Given your subject matter you might find this useful:

http://www.dabhand.org/ECL/construct_a_ ... search.htm

David
dabayliss
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 109
Joined: Fri Apr 29, 2011 1:35 pm

Thu Oct 06, 2011 12:37 pm Change Time Zone

Thanks dabayliss,

I'd actually found this web site and took the idea of using the Bible from it. Though decided to try a simpler example, as, for example, I could not find 'GetNthWord', used by author, in the ECL reference manual.

I've been though LN's training videos and some, not all, documentation, and it not at all clear from these sources that, by default, a single definition can be exported from a file.

It seems a strange decision to tie what you can do in a program to the environment the program is compiling under i.e. the file name of containing file?

In C++ its good practice to have a single class in a file and tie the class name to the filename, but its not at all mandatory.

Yours - gradually making headway.

Allan
Allan
 
Posts: 430
Joined: Sat Oct 01, 2011 7:26 pm

Thu Oct 06, 2011 12:54 pm Change Time Zone

GetNthWord is part of the ECL standard libraries - the routines are not yet documented in our language reference; but if you look in the ecllibrary directory (you can see it from the ECL IDL) all of the routines are visible to see and well documented.

The strangeness of the decision to encapsulate the code according to its logical structure depends upon where you are coming from. As someone who started in Pascal & Modula-2 it would strike me as very strange to allow code to leak all over your source files ....

David
dabayliss
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 109
Joined: Fri Apr 29, 2011 1:35 pm

Thu Oct 06, 2011 4:04 pm Change Time Zone

Hi dabayliss,

Great - Thanks for pointing me to those libraries, I'll be reading those up.

As to the 'strangeness', your right its only a personal judgment. I was just peeved that this restriction is not documented. If it is, its not made prominent enough in the tutorials. I spent a good two evenings stuck on that point.

Yours

Allan
Allan
 
Posts: 430
Joined: Sat Oct 01, 2011 7:26 pm

Next

Return to ECL

Who is online

Users browsing this forum: No registered users and 1 guest