The defined() function is written using the 3.x API and cannot differentiate between undefined and the empty string. Moving the function to the 4.x function API solves that issue.
The second issue is if the main class (known as '' internally) really should be available under that name. Everyone knows it as "main", and it is not possible to create your own "main" class without causing strange side effects.
Further, it is not possible to ask specifically if a class foo is defined, or if a resource type foo is defined using the current version of the function since
a request for Class[foo] requires that the class is included in the catalog, and a request for 'foo' is satisfied by either a built in type, a define
or a class. For a resource type (built in or user defined) it is possible to ask for only the type e.g. File, or Resource[File]. To facilitate this, and for completeness, it should be possible to ask if Type[Class[foo]] is defined (as well as Type[Resource[T]] (even if the later is not absolutely required).
The solutions (in PR 3840) produces:
When defined is used with the future parser on 3.x, and always on 4.x
severity: medium (confusing, can cause code to be unpredictable, but work arounds exist)
test layer: unit