User loginNavigation |
archivesNamespaces for methods?I'm working on adding namespaces to messages in my programming language. I've run into a few... strange... side-effects of it that I'd appreciate some feedback on. The motivation here is that since classes are open to extension, namespaces will let you add methods to existing classes while avoiding collisions. For example: // In document.mag: class Document // Stuff... end // In render.mag: def Document print() // Code to draw the document on-screen... end // In printer.mag: def Document print() // Code to send the document to a printer... end // Later... var document = Document new() document print() // Which one?
Here, the two // In render.mag: def Document render.print() // Code to draw the document on-screen... end // In printer.mag: def Document printer.print() // Code to send the document to a printer... end
You can select a specific document render.print() Or by importing the namespace: using render document print()
When it encounters a message like So, here's where you come in (I hope). There's two consequences of this that feel wrong: Dispatching a method is The fully-qualified name that's resolved for a method may be different at runtime depending on the value of the receiver. This is the part that feels really strange. Consider: class Foo def apple.method() "apple" end class Bar def banana.method() "banana" end def callMethod(obj) using apple using banana obj method() end callMethod(Foo new()) // "apple" callMethod(Bar new()) // "banana" At runtime, an unqualified name may resolve to a different namespace based on the method set of the receiver. That runs counter to my intuition of namespaces. I consider an unqualified name in a scope with an imported namespace to just be a shorthand for the one "real" fully-qualified name that it represents. This implementation doesn't work that way. Instead, an unqualified name with imported namespaces defines a set of possible names, any of which are potentially valid based on the receiver. That's a valid semantic, but one that feels unusual to me. So, questions:
Thanks! Schemas for JSON?I'm seeing a big gap in the world right now in re: schemas for JSON. In particular, it appears to me that a large fraction of the world (well, okay, of the people who are encoding data in language-neutral ways) has the wrong impression about JSON, believing that its fundamental difference from XML is its simplicity, when in fact (I claim) JSON's raison d'etre is the fact that it didn't start life as a markup language. If you believe me, then in fact schemas for JSON values are in fact extremely valuable. I see one proposal on the web, but my brief reading of it suggests that we can perhaps do better. Is there a bunch of work on this that I'm just not aware of? Apologies in advance for offending anyone, or for failing to be aware of obvious answers to my question. Thanks! |
Browse archivesActive forum topics |
Recent comments
36 weeks 2 days ago
36 weeks 2 days ago
36 weeks 2 days ago
1 year 6 weeks ago
1 year 10 weeks ago
1 year 12 weeks ago
1 year 12 weeks ago
1 year 14 weeks ago
1 year 19 weeks ago
1 year 19 weeks ago