Null implementations

8 views
Skip to first unread message

John J. Camilleri

unread,
May 22, 2012, 3:40:57 AM5/22/12
to gf-...@googlegroups.com
I have certain abstract categories & functions which I don't want to implement in some concrete syntaxes.
I could just leave them out and get some compiler warnings, but is there such a thing as a null implementation in GF? What I mean is some way of creating a linearisation placeholder which satisfies the compiler, but in reality produces nothing. I could construct such things manually for each type, but I wonder if there is some oper which already does this?
Is this acceptable as a design pattern, or is having null implementations somehow discouraged in GF?

peter ljunglöf

unread,
May 22, 2012, 3:59:16 AM5/22/12
to gf-...@googlegroups.com
How about this:

lin f = variants {};

/Peter

Krasimir Angelov

unread,
May 22, 2012, 3:59:07 AM5/22/12
to gf-...@googlegroups.com
you can do something like:

lin f = variants {}

This will not generate any code in the compiled grammar and you will
avoid the warnings.

2012/5/22 John J. Camilleri <jo...@johnjcamilleri.com>:

John J. Camilleri

unread,
May 22, 2012, 4:10:39 AM5/22/12
to gf-...@googlegroups.com
Yes thanks that works.
I was trying to use Predef.Error, which is the same type but apparently is treated specially by the compiler.

What is the difference between
lin f = variants {} ;
and
lin f = {} ;
?

John J. Camilleri

unread,
May 22, 2012, 4:24:13 AM5/22/12
to gf-...@googlegroups.com
Never mind, got it now. Thanks.
Reply all
Reply to author
Forward
0 new messages