Problem with Scope Type Parameter
Posted: 9 Jun 2015 9:53
Hello Thomas,
using the Support pattern I came across a problem. Please have a look at my construct.
I start demonstrating the issue from the following code, which works out fine:
In the above code the dummy domains seem superfluous. When removing them the code becomes:
However on above code the compiler throws the (supposably incorrect) error c352 : Unused type parameter '@Type' at two places. To cure the errors I also remove the scope type parameters which are reported to be unused and come to the below version of the code:
The above code compiles, but when running it, the call Obj:doSomething("I am a test") provokes an access violation.
Many regards
Martin
using the Support pattern I came across a problem. Please have a look at my construct.
I start demonstrating the issue from the following code, which works out fine:
Code: Select all
interface myDomain{@Type}
domains
type = @Type.
end interface myDomain
%======
interface obj{@Type}
open myDomain{@Type}
predicates
doSomething : (type Val).
predicates
doSomethingElse : (type Val).
end interface obj
%---
class obj{@Type} : obj{@Type}
end class obj
%---
implement obj{@Type}
supports objSite{@Type}
inherits objSupport{@Type}
clauses
new() :-
objSupport::new(This).
clauses
doSomething(Val) :-
stdIo::write(Val).
end implement obj
%======
interface objSite{@Type}
domains
dummy = @Type.
predicates from obj{@Type}
doSomething/1
end interface objSite
%======
interface objSupport{@Type}
domains
dummy = @Type.
predicates from obj{@Type}
doSomethingElse/1
end interface objSupport
%---
class objSupport{@Type} : objSupport{@Type}
constructors
new : (objSite{@Type}).
end class objSupport
%---
implement objSupport{@Type}
supports objSite{@Type}
delegate interface objSite{@Type} to site
facts
site : objSite{@Type}.
clauses
new(ObjSite) :-
site := ObjSite.
clauses
doSomethingElse(Val) :-
doSomething(Val).
end implement objSupport
%======
implement main
clauses
run() :-
Obj = obj::new(),
Obj:doSomething("I am a test").
end implement main
goal
console::runUtf8(main::run).
Code: Select all
interface myDomain{@Type}
domains
type = @Type.
end interface myDomain
%======
interface obj{@Type}
open myDomain{@Type}
predicates
doSomething : (type Val).
predicates
doSomethingElse : (type Val).
end interface obj
%---
class obj{@Type} : obj{@Type}
end class obj
%---
implement obj{@Type}
supports objSite{@Type}
inherits objSupport{@Type}
clauses
new() :-
objSupport::new(This).
clauses
doSomething(Val) :-
stdIo::write(Val).
end implement obj
%======
interface objSite{@Type}
predicates from obj{@Type}
doSomething/1
end interface objSite
%======
interface objSupport{@Type}
predicates from obj{@Type}
doSomethingElse/1
end interface objSupport
%---
class objSupport{@Type} : objSupport{@Type}
constructors
new : (objSite{@Type}).
end class objSupport
%---
implement objSupport{@Type}
supports objSite{@Type}
delegate interface objSite{@Type} to site
facts
site : objSite{@Type}.
clauses
new(ObjSite) :-
site := ObjSite.
clauses
doSomethingElse(Val) :-
doSomething(Val).
end implement objSupport
%======
implement main
clauses
run() :-
Obj = obj::new(),
Obj:doSomething("I am a test").
end implement main
goal
console::runUtf8(main::run).
Code: Select all
interface myDomain{@Type}
domains
type = @Type.
end interface myDomain
%======
interface obj{@Type}
open myDomain{@Type}
predicates
doSomething : (type Val).
predicates
doSomethingElse : (type Val).
end interface obj
%---
class obj{@Type} : obj{@Type}
end class obj
%---
implement obj{@Type}
supports objSite
inherits objSupport
clauses
new() :-
objSupport::new(This).
clauses
doSomething(Val) :-
stdIo::write(Val).
end implement obj
%======
interface objSite
predicates from obj{_Type}
doSomething/1
end interface objSite
%======
interface objSupport
predicates from obj{_Type}
doSomethingElse/1
end interface objSupport
%---
class objSupport : objSupport
constructors
new : (objSite).
end class objSupport
%---
implement objSupport
supports objSite
delegate interface objSite to site
facts
site : objSite.
clauses
new(ObjSite) :-
site := ObjSite.
clauses
doSomethingElse(Val) :-
doSomething(Val).
end implement objSupport
%======
implement main
clauses
run() :-
Obj = obj::new(),
Obj:doSomething("I am a test").
end implement main
goal
console::runUtf8(main::run).
Many regards
Martin