You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rename __reql_type__ to $__reql_type__ in all current proposals #1149
(I realize I'm breaking our timeboxing rules, but this seems like an incredibly easy fix that it would be really really good to get right the first time.)
No objections. It's ugly, but if that's what others use, we should too. One caveat is that if people use dollar sign for magic values $reql_type might be better than $__reql_type__. Let's just follow whichever conventions already exist as closely as we can.
I sort of prefer $__reql_type__ because it seems an order of magnitude less likely to cause a conflict, and because frankly magic strings should be ugly sometimes. I could plausibly imagine myself typing $reql_type in a normal ruby program because global variables start with $; I can't imagine myself typing $__reql_type__ in a normal ruby program.
Eh, I feel like if $ is the standard then we should use only that (i.e. $reql_type) and if we're not satisfied that it's sufficiently resistant to collisions then we should use something else. Combining 2 standards just seems weird and like it's not going to feel familiar to people who know either standard.
I don't quite follow; $__reql_type__ isn't a violation of the standard "special JSON keys start with a $", it's a key that follows that standard and is extra resistant to collisions.
It might not be a violation of the standard but it still looks odd because it's clearly inspired by python's treatment of magic values and json's treatment of magic values. I can't actually find an example of anyone using this standard (although it's pretty hard to google) but I'm betting they don't normally add underscores as well as the $ sign.
@coffeemug Users are actually going to see this value pretty quickly I think. Neither javascript nor Ruby has a native duration type so all it's going to take is someone writing a query like:
and they're going to be getting back raw psuedo types. I feel like $__reql_type__ is just needlessly ugly and something users will being seeing fairly frequently (and something driver developers will be typing fairly frequently). My preferences would be:
__reql_type__ (very readable, and I've really yet to see evidence that this is an actual standard)
Also I'm increasingly dubious that this is in anyway a standard, the number one hit on google for "dollar magic values JSON" is this issue and I can't find a single other mention of it. Also google has a JSON style guideline which makes no mention of this.
1 is better than 3 which is better than 2 from my point of view. Both 1 and 3 are fine. I'm just not a big fan of 2 since it means "global variable" for me.
Anyway, since I'm not working on the internals of ReQL, I don't have a strong opinion on that.
@coffeemug Users are actually going to see this value pretty quickly I think. Neither javascript nor Ruby has a native duration type
This is why, however we choose to represent such types on the server, I would prefer to add a datum type to the protobuf spec than simply return the object with the obfuscated field. This way the driver implementer is forced to choose a representation that makes sense for that language. For languages that support native date types this would mean converting to and from the native date type without having to scan every object for a special key.
For languages that don't have a native type, the driver implementor will be forced to choose a representation. I can almost guarantee that few would choose to return an object (or dict, or hash, or map) with a special key that the user then has to deal with. Most likely, the driver would create a custom class or type to represent the ReQL date and duration types. However we handle it internally, we should nudge them towards this solution. Getting this to happen is way more important for user experience than the choice between __reql_type__, $reql_type, and $__reql_type__.
@coffeemug Users are actually going to see this value pretty quickly I think.
I think that for things like duration we might want to convert the reql object to raw numbers on the driver side. It will lose the property that we can put it back in and get the same type, but I think it's way friendlier than the alternative.
In any case, I don't have a strong opinion on this. Whatever we choose is fine by me.
We generally are too paranoid about conflicts. For some history of this kind of decision, see the browser-prefixes fiasco in CSS, see the X- prefix fiasco in headers. Going with $type or __type__ should be fine.
Also (sorry for the stream of consciousness thing going here), to use $__reql_type__ or $reql_type$ means we're actually planning for a world where both $reql_type and $reql_type$ exist and are used and have different, incompatible meanings. We are actually trying to facilitate this future timeline.
But, by choosing $reql_type we'd be facilitating a world where both $reql_type and $ql_type exist but have different meanings. By induction, we should clearly use the empty string for our magic constant name.
There are good reasons (that I'd think would be obvious) why we'd use the field name $reql_type and not $rql_type, $reql_typ, or reql_type. Two are misspellings and one is missing the dollar sign prefix. There isn't a good reason to use $reql_type$ and not $reql_type.
It was just a joke meant to demonstrate the problem with saying "well, if we pick this name, we'd be implicitly endorsing people using a shorter name for their own purposes" -- namely, that the new shorter name would, by that same logic, be endorsing an even shorter name.
Activity
coffeemug commentedon Jul 9, 2013
No objections. It's ugly, but if that's what others use, we should too. One caveat is that if people use dollar sign for magic values
$reql_typemight be better than$__reql_type__. Let's just follow whichever conventions already exist as closely as we can.mlucy commentedon Jul 9, 2013
I sort of prefer
$__reql_type__because it seems an order of magnitude less likely to cause a conflict, and because frankly magic strings should be ugly sometimes. I could plausibly imagine myself typing$reql_typein a normal ruby program because global variables start with$; I can't imagine myself typing$__reql_type__in a normal ruby program.coffeemug commentedon Jul 9, 2013
Ok. I don't feel strongly about this.
jdoliner commentedon Jul 9, 2013
Eh, I feel like if
$is the standard then we should use only that (i.e.$reql_type) and if we're not satisfied that it's sufficiently resistant to collisions then we should use something else. Combining 2 standards just seems weird and like it's not going to feel familiar to people who know either standard.mlucy commentedon Jul 10, 2013
I don't quite follow;
$__reql_type__isn't a violation of the standard "special JSON keys start with a$", it's a key that follows that standard and is extra resistant to collisions.jdoliner commentedon Jul 10, 2013
It might not be a violation of the standard but it still looks odd because it's clearly inspired by python's treatment of magic values and json's treatment of magic values. I can't actually find an example of anyone using this standard (although it's pretty hard to google) but I'm betting they don't normally add underscores as well as the
$sign.coffeemug commentedon Jul 10, 2013
This is a bike we all want to shed :)
mlucy commentedon Jul 10, 2013
My preferences, in order:
$__reql_type__(kinda ugly)__reql_type__(supposedly not in line with an informal standard)$reql_type(in line with the standard but also something I could plausibly type)coffeemug commentedon Jul 10, 2013
I really think
$__reql_type__is cool. It's obviously ugly, but I really don't think it matters. Most users will never ever see this anyway.jdoliner commentedon Jul 10, 2013
@coffeemug Users are actually going to see this value pretty quickly I think. Neither javascript nor Ruby has a native duration type so all it's going to take is someone writing a query like:
and they're going to be getting back raw psuedo types. I feel like
$__reql_type__is just needlessly ugly and something users will being seeing fairly frequently (and something driver developers will be typing fairly frequently). My preferences would be:__reql_type__(very readable, and I've really yet to see evidence that this is an actual standard)$reql_type(also fairly readable, perhaps collision prone)$__reql_type__(needlessly ugly)Also I'm increasingly dubious that this is in anyway a standard, the number one hit on google for "dollar magic values JSON" is this issue and I can't find a single other mention of it. Also google has a JSON style guideline which makes no mention of this.
neumino commentedon Jul 10, 2013
1 is better than 3 which is better than 2 from my point of view. Both 1 and 3 are fine. I'm just not a big fan of 2 since it means "global variable" for me.
Anyway, since I'm not working on the internals of ReQL, I don't have a strong opinion on that.
wmrowan commentedon Jul 10, 2013
This is why, however we choose to represent such types on the server, I would prefer to add a datum type to the protobuf spec than simply return the object with the obfuscated field. This way the driver implementer is forced to choose a representation that makes sense for that language. For languages that support native date types this would mean converting to and from the native date type without having to scan every object for a special key.
For languages that don't have a native type, the driver implementor will be forced to choose a representation. I can almost guarantee that few would choose to return an object (or dict, or hash, or map) with a special key that the user then has to deal with. Most likely, the driver would create a custom class or type to represent the ReQL date and duration types. However we handle it internally, we should nudge them towards this solution. Getting this to happen is way more important for user experience than the choice between
__reql_type__,$reql_type, and$__reql_type__.coffeemug commentedon Jul 10, 2013
I think that for things like duration we might want to convert the reql object to raw numbers on the driver side. It will lose the property that we can put it back in and get the same type, but I think it's way friendlier than the alternative.
In any case, I don't have a strong opinion on this. Whatever we choose is fine by me.
srh commentedon Jul 10, 2013
We generally are too paranoid about conflicts. For some history of this kind of decision, see the browser-prefixes fiasco in CSS, see the X- prefix fiasco in headers. Going with
$typeor__type__should be fine.13 remaining items
jdoliner commentedon Jul 13, 2013
I'm fine with
$reql_type$srh commentedon Jul 13, 2013
I don't get what's so worrisome about $reql_type.
srh commentedon Jul 13, 2013
In particular: Is anybody using $reql_type right now? (No.) Is anybody going to start using it once we lay claim to it? (No.)
srh commentedon Jul 13, 2013
Also (sorry for the stream of consciousness thing going here), to use
$__reql_type__or$reql_type$means we're actually planning for a world where both$reql_typeand$reql_type$exist and are used and have different, incompatible meanings. We are actually trying to facilitate this future timeline.mlucy commentedon Jul 14, 2013
But, by choosing
$reql_typewe'd be facilitating a world where both$reql_typeand$ql_typeexist but have different meanings. By induction, we should clearly use the empty string for our magic constant name.srh commentedon Jul 14, 2013
Why would it be a problem for
$reql_typeand$ql_typeto have different meanings?mlucy commentedon Jul 14, 2013
Well,
$reql_typeand$rql_type, then. Or$reql_typeandreql_type. Or$reql_typeand$reql_typ.srh commentedon Jul 14, 2013
There are good reasons (that I'd think would be obvious) why we'd use the field name $reql_type and not $rql_type, $reql_typ, or reql_type. Two are misspellings and one is missing the dollar sign prefix. There isn't a good reason to use$reql_type$ and not $reql_type.
mlucy commentedon Jul 15, 2013
It was just a joke meant to demonstrate the problem with saying "well, if we pick this name, we'd be implicitly endorsing people using a shorter name for their own purposes" -- namely, that the new shorter name would, by that same logic, be endorsing an even shorter name.
srh commentedon Jul 15, 2013
Well then, clearly you're a cryptoendorser of
~.Xx__^-^__$reql_type$__^-^__xX.~.mlucy commentedon Jul 15, 2013
That doesn't start with a
$.mlucy commentedon Jul 15, 2013
Although, this is a possibly-once-in-a-lifetime opportunity to work
^.^into a magic constant that other people might have to type one day.mlucy commentedon Jul 17, 2013
Alright, I'm calling this in the interests of shipping this thing before the sun burns down to cold, dead cinder.
Let's go with
$reql_type$. We will claim the right to all keys of the form^\$reql_.+\$$.mlucy commentedon Jul 17, 2013
@jdoliner, could you update the dates code?