You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Jeff Hodges (JIRA)" <ji...@apache.org> on 2010/04/28 10:13:32 UTC

[jira] Commented: (AVRO-530) allow for mutual recursion in type definitions

    [ https://issues.apache.org/jira/browse/AVRO-530?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12861717#action_12861717 ] 

Jeff Hodges commented on AVRO-530:
----------------------------------

(It could be done in one pass, of course. That was just an off-the-cuff idea that I thought would be easier to write but might not be.)

> allow for mutual recursion in type definitions
> ----------------------------------------------
>
>                 Key: AVRO-530
>                 URL: https://issues.apache.org/jira/browse/AVRO-530
>             Project: Avro
>          Issue Type: Improvement
>          Components: spec
>    Affects Versions: 1.3.2
>            Reporter: Jeff Hodges
>
> Suppose you have these two types in your protocol:
> {code}
> {"name": "User", "type": "record", "fields": [{"name": "current_status", "type": "Status"}]}
> {"name": "Status", "type": "record", "fields": [{"name": "author", "type": "User"}]}
> {code}
> This will raise an error! The current workaround is to define one of them at their first usage. Like:
> {code}
> {"name": "User", "type": "record", "fields": [{"name": "current_status", "type": {"name": "Status", "type": "record", "fields": [.. lots of fields ...]}]}
> {code}
> But this is incredibly unwieldy. It would be really nice for the spec to require all the parsers to allow for mutual recursion, instead. It could be done by implementing a two-pass parser. One pass to acquire names referenced, and a second to fill in those names with their appropriate references.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.