Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use data instead of fun so pattern-matching on def's is possible #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

odanoburu
Copy link
Contributor

are there any drawbacks to these changes? (e.g., performance-wise?) I found that several constructs were already declared as data, but some were not.

@krangelov
Copy link
Member

krangelov commented Aug 15, 2018 via email

@odanoburu
Copy link
Contributor Author

@krangelov thanks for the answer!

when you say "in the same module" you mean literally in the same file, or would an extension (**) of that file also work? if the later is fine, this is why this PR seems work alright (not only the CI build, but I've been using this patch now). if so, can we merge this? (as I said, these are not the only data declarations, the RGL is already full of them!)

However, I am not sure that the compiler checks that restriction.

it does, I tried adding data the grammar I was developing and got an error!

@krangelov
Copy link
Member

krangelov commented Aug 16, 2018 via email

@odanoburu
Copy link
Contributor Author

odanoburu commented Aug 16, 2018

sorry, I wasn't very clear: I meant extended modules, not extended types! i.e., the RGL has several cases of data declarations that occur in modules that extend the Cat module. I'm merely adding some more; is that ok? if not, I guess I'm misunderstanding something -- can you provide an example?

@odanoburu odanoburu closed this Aug 16, 2018
@odanoburu
Copy link
Contributor Author

odanoburu commented Aug 16, 2018

misclicked the close button, sorry.

@odanoburu odanoburu reopened this Aug 16, 2018
@inariksit
Copy link
Member

@krangelov So what was the conclusion, does "against the language specification" mean that we should not merge this, or do we not care?

@krangelov
Copy link
Member

krangelov commented Aug 21, 2018 via email

@odanoburu
Copy link
Contributor Author

@krangelov should I make a PR removing the existing instances of this problem?

Anyway if you want to pattern match on trees it is so far simpler to do it outside GF.

yes, but at the cost of another dependency..

@hleiss
Copy link
Contributor

hleiss commented Nov 17, 2023

My opinion on this old question is:
of course, tree transformations ought to be definable in GF itself, as part of the RGL; so most fun's should be data's.

a) one might want to define a tree normalization nf : trees -> trees, e.g. to transform trees with possessive genitive attribute, PossNP cn np, to trees with attributive possessive pronoun, DetCN (DetQuant (PossPron pron) num) cn, in case np is a (UsePron pron).
b) a good translation between languages will need tree transformations, e.g. Ancient Greek has 11 participles, while Eng or Ger etc. have only 2. So, to express the intended meaning properly in Eng or Ger, many Greek participle constructions need to be transformed to relative or adverbial clauses in Eng or Ger etc. (and reversely, perhaps).

The data constructors in the RGL are in Noun, Numeral, Sentence, Verb with result types like Card, Digit, Numeral Cl, VP etc. that are defined in Cat. So, clearly the compiler does not enforce the restriction of C.3.6 mentioned by Krasimir.
(On the other hand, C.3.6 says that (instead of data f : A -> C) we can say fun f : A -> C ; data C = f , while the compiler says this is conflicting information on f.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants