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

tag_class has to be a class. #14

Closed
jjwatt opened this issue Nov 26, 2013 · 2 comments
Closed

tag_class has to be a class. #14

jjwatt opened this issue Nov 26, 2013 · 2 comments

Comments

@jjwatt
Copy link

jjwatt commented Nov 26, 2013

Since we're targeting the clojure data format, why not support tag handlers through simple functions instead of requiring a TaggedElement class?

The nice thing is that if you only want to go in one direction, =edn_format.add_tag(myfunc, 'mytag')= already works.

It would be relatively simple to just take one or two functions instead of a class for handlers.

It would also be nice if the module functions like =edn_format.dumps= and =edn_format.loads= took optional functions as parameters for handlers.

@bfontaine
Copy link
Collaborator

Isn’t that already possible?

>>> from edn_format import add_tag, loads
>>> def my_verbose_tag(el):
...     print("Hey I got %s" % el)
...     return el
... 
>>> add_tag("verbose", my_verbose_tag)
>>> loads("#verbose 42")
Hey I got 42
42

@bfontaine
Copy link
Collaborator

It would also be nice if the module functions like =edn_format.dumps= and =edn_format.loads= took optional functions as parameters for handlers.

Do you mind making a pull-request?

I’m closing this since it doesn’t seem to be an issue. Please reopen if you think it is. Thanks!

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

No branches or pull requests

2 participants