In WebDSL are extended entities just partial classes in C#.

entity Issue {
  ...
}
extend entity Issue {
  ...
}

They are however asymmetric, there is a single entity definition and zero or more extended entity definitions.

The current NaBL solution for this would be to defines non-unique Entity e but this has a big drawback: one does not get an error if there is a typo in the extended entity name.

To solve this the extended entities need to be uses of a name rather than a non-unique definition. This gives errors on non existing entity names and provides support for ctrl-click to the entity definition site. However, then the extended entity cannot define new fields and functions.

So, I tried combining both (in a very similar use case in the relations language), making it both a defines non-unique and a refers to at the same time. I couldn’t get this to work.

Any suggestions on solving this?

  • defines non-unique combined with refers to is the preferred solution?
  • or an asymmetric defines unique and defines non-unique NaBL solution?
  • or defines in a where a can be any resolved NaBL uri (conditional definitions, which wont work with the current task engine)?
Submitted by Daco Harkes on 20 November 2014 at 11:27

On 20 November 2014 at 11:39 Guido Wachsmuth commented:

You can try to duplicate the names in a preprocessing step:

normalise: Entity(x, m*) -> Entity(x, Base(x), m*)
normalise: ExtEntity(x, m*) -> Entity(x, Ext(x), m*)

And use two different namespaces:

Entity(x, _, _): defines non-unique Entity x scopes ...

Base(x): defines BaseEntity x
Ext(x): refers to BaseEntity x

On 20 November 2014 at 11:41 Daco Harkes commented:

Also defining two entity Issue{ ... } will not trigger duplicate definition errors when defines non-unqiue is used.

workaround

Define the entities both uniquely and non uniquely on the ‘non extended’ sites.

Entity(e-ty, ...)
  defines Entity2 e-ty
  defines non-unique Entity e-ty

On 20 November 2014 at 11:51 Guido Wachsmuth commented:

The workaround I described should trigger duplicate errors. Your workaround might not work well with scoping. If it does, its kind of fragile.


On 24 November 2014 at 15:54 Daco Harkes commented:

Duplicating names works for unresolved reference errors.
Adding extra constructors Base and Ext is not required.

It does however not provide resolving references in the editor. (Not even if the use annotation is on the first name.)
Any other suggestions?


On 27 November 2014 at 17:12 Daco Harkes commented:
Resolve relation member to entity [[
	entity [[User]]{}
	entity Book{}
	relation Owns{
		[[User]] *
		Book 1
	}
]] resolve #2 to #1

Funky, the testcases for resolving works while cmd/ctrl+click in the editor doesn’t work.


On 1 December 2014 at 11:51 Daco Harkes commented:

cmd/ctrl+click can be fixed by tweaking editor resolve:

editor-resolve:
	(node, position, ast, path, project-path) -> definition
	where
		node' := <try(resolve-child)>node;
		definition := <analysis-resolve(|<language>, project-path)> node'

resolve-child: NaBLHelp(name, _) -> name

On 1 December 2014 at 11:52 Daco Harkes commented:

@Guido do you want to keep this issue open as a reminder to make a future NaBL support this use case?

Log in to post comments