1. Advice on converting archive files from 3.1.1 to 4.0

I thought some general advice on where to start when converting library files from the archive to work with 4.0 might be helpful.

As I see it there are basically no syntax changes syntax changes which should have any effect. All the new keywords and constructs are additive rather than subtractive of v3.

Namespaces

The problem seems to be namespaces ... and I understand the incompatible to arise for the following reasons:

Because of :

  1. the resolution of forward references in v4; and because
  2. included files don't have access to the namespace of the file which includes them (or any library files that the calling file has included);

it is necessary to specifically include each subfile which the library relies on at its start .. and so on down the line for each of the files which it includes.

(Perhaps this might be solved by a special version of include called include_compatible which resolves the namespaces in the previous way? )

Are there any other gotchas or elements that fundamentally change the way an existing v3 program is implemented in v4 that would cause it to break?

(sorry if this topic has been covered elsewhere but I haven't been able to find it in the forum)

Jansek

(thanks for all the fantastic advice people have taken the trouble to put on this forum. It's appreciated)

new topic     » topic index » view message » categorize

2. Re: Advice on converting archive files from 3.1.1 to 4.0

JansekVillaria said...

Namespaces

The problem seems to be namespaces ... and I understand the incompatible to arise for the following reasons:

Actually, I think most 3.1 code will work out of the box for 4.0.

JansekVillaria said...

Because of :

  1. the resolution of forward references in v4; and because
  2. included files don't have access to the namespace of the file which includes them (or any library files that the calling file has included);

it is necessary to specifically include each subfile which the library relies on at its start .. and so on down the line for each of the files which it includes.

(Perhaps this might be solved by a special version of include called include_compatible which resolves the namespaces in the previous way? )

Technically, it is only necessary if the symbols in the file are not global. 4.0 will still resolve global symbols in files not directly included. It's always been true that files don't have access to the namespace of any other file, since a namespace was treated as a local symbol in 3.1. A file still has access to symbols in the global scope of a file that included it. This should be considered bad practice, however.

With 4.0, the recommended practice is to use public or export scopes for your symbols in place of global, and to use include statements to specify the files containing the symbols your code will use. Simply doing this typically removes most namespace conflicts, as the parser can choose between symbols based on a clear expression of the programmer's intent.

One thing to look out for is mixing the 3.1 standard library with the 4.0 standard library. If you are using a library that uses the older library, but are using the newer one in your code, there is some help for that by using indirect_includes:

without indirect_includes 
include legacy_library.e 
 
-- rest of your code 

The effect of this will be to keep the globals from the files included by legacy_library.e from clashing with your code.

JansekVillaria said...

Are there any other gotchas or elements that fundamentally change the way an existing v3 program is implemented in v4 that would cause it to break?

(sorry if this topic has been covered elsewhere but I haven't been able to find it in the forum)

There probably are. We had a wiki page listing some of these issues (can't find it now), and there's the start of something that introduces new things in 4.0.

Matt

new topic     » goto parent     » topic index » view message » categorize

3. Re: Advice on converting archive files from 3.1.1 to 4.0

JansekVillaria said...

I thought some general advice on where to start when converting library files from the archive to work with 4.0 might be helpful.

As I see it there are basically no syntax changes syntax changes which should have any effect. All the new keywords and constructs are additive rather than subtractive of v3.

Namespaces

The problem seems to be namespaces ... and I understand the incompatible to arise for the following reasons:

Because of :

  1. the resolution of forward references in v4; and because
  2. included files don't have access to the namespace of the file which includes them (or any library files that the calling file has included);

it is necessary to specifically include each subfile which the library relies on at its start .. and so on down the line for each of the files which it includes.

(Perhaps this might be solved by a special version of include called include_compatible which resolves the namespaces in the previous way? )

Are there any other gotchas or elements that fundamentally change the way an existing v3 program is implemented in v4 that would cause it to break?

(sorry if this topic has been covered elsewhere but I haven't been able to find it in the forum)

Jansek

(thanks for all the fantastic advice people have taken the trouble to put on this forum. It's appreciated)

Also:

ver 4.0 keyword names and function names may conflict with
names used in the ver. 3.11 or older code.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Advice on converting archive files from 3.1.1 to 4.0

Thank you for the lucid explanation especially of indirect_includes.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu