Wish Libraries and namespace conflicts?

warwound

Expert
Licensed User
Longtime User
Is there an existing solution where different library objects have identical ShortNames?

If not could the IDE detect where there are duplicate object names and allow the use of the fully qualified name for each object instead of it's ShortName?

I'm thinking that this will become more of a problem as times goes by and if a solution is found now it will save lots of time in the future.
Sure we can create libraries objects with a unique prefix added to each ShortName to anticipate a problem, but my suggestion would i think be more flexible.

It wouldn't require the library writer to decide 'is this object name likely to have already been used or is this object name likely to be used in the future by another library writer?'.
In fact to answer the question 'is this object name already being used?' is itself a tricky one to answer unless you have time to download and inspect all currently available libraries.

Any comments?

Martin.
 

warwound

Expert
Licensed User
Longtime User
Different libraries can have the same ShortName if they are not referenced at the same time. Currently it is not possible to reference two libraries that include types with the same shortname.

Yes but my request/question is are there plans to make it possible to use libraries where an object ShortName is already used by another (in use) library in a single b4a project?

Currently the only solution i know of is to ask the one of the library writers to re-compile their library - such a solution produces a library update that is not compatible with previous versions of that library.

Martin.
 

Vader

Well-Known Member
Licensed User
Longtime User
I could add a feature to the B4A Browser that shows conflicts with library short names so that you at least aware of the issue before you try and use the two libraries together. Would that help?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Yes but my request/question is are there plans to make it possible to use libraries where an object ShortName is already used by another (in use) library in a single b4a project?
This requires a namespace feature similar to Java namespaces. For now I do not plan to add such a feature as in almost all cases it will only make the code more "cumbersome" and error prone.

There shouldn't be two types with the same name. It is too confusing. Check for example java.sql.Date and java.util.Date. A developer who is less experienced with Java can easily mix between the two without understanding the strange errors that will occur.
 

warwound

Expert
Licensed User
Longtime User
I could add a feature to the B4A Browser that shows conflicts with library short names so that you at least aware of the issue before you try and use the two libraries together. Would that help?

That'd be useful - it'd be interesting to see how many libraries in my additional libraries folder currently have conflicting ShortNames.

This requires a namespace feature similar to Java namespaces. For now I do not plan to add such a feature as in almost all cases it will only make the code more "cumbersome" and error prone.

Yes it'd instantly make B4A less user friendly to people not familiar with fully qualified names.

My reason for starting this thread though was really to find out if others had wondered if or when ShortName conflicts will become a problem in B4A.

If the B4A IDE enumerated all currently enabled library ShortNames and could generate a unique ShortName where there is a conflict.

So OSMDroid and GoogleMaps libraries both have Marker objects.
If both libraries were used in the same project the IDE could enumerate OSMDroid_Marker and GoogleMaps_Marker - that'd be less confusing that resorting to fully qualified java class names i think?

But such an update to the IDE would have to anticipate that the user might copy/paste code from a project where ShortNames conflict to another project where there is no conflict.
In the project with no ShortName conflict the copy/pasted code would reference OSMDroid_Marker for example and this would no longer be necessary.
Again confusion is likely to be caused.

Anyway for now the best option must be to choose a ShortName that's unlikely to be duplicated when compiling a library.

Martin.
 

Vader

Well-Known Member
Licensed User
Longtime User
FYI, I have a bunch of additional libraries on my PC and none of them have duplicate short-names. Having said that though, I have also wondered what would happen if there was a duplicate (as I am populating a TreeView control with this information).

The plan is that I will put some visual indication of any conflicts into the OB.
 

Vader

Well-Known Member
Licensed User
Longtime User
Oh btw, can someone confirm that we are talking about duplicate Class Short-names, not library? Libraries don't have a "name" other than the filename.
 

Vader

Well-Known Member
Licensed User
Longtime User
Assuming that we are indeed talking about Classes, this is now done and will appear in the next OB update.
 
Last edited:
Top