These are chat archives for Ren-data/Ren/map

18th
Jun 2015
PeterWAWood
@PeterWAWood
Jun 18 2015 08:25
Given that both Red maps! and JavaScript Arrays support string "key" values, shouldn't Ren allow string "key" values in maps?
Nenad Rakocevic
@dockimbel
Jun 18 2015 08:54
Doesn't R3 also support string keys in map? (Can't check it right now)
Boleslav Březovský
@rebolek
Jun 18 2015 08:55
it does
PeterWAWood
@PeterWAWood
Jun 18 2015 09:15
I guess the downside is that some languages won't be able to handle string keys. Perhaps that's why Douglas Crockford didn't cope for them in JSON>
Sorry, it seems that I'm wrong and the JSON does allow string keys. This was deemed valid by JSONlint:
{
    "a": 1,
    "\"a\"": 2
}
Gregg Irwin
@greggirwin
Jun 18 2015 16:17
This is tricky. JSON calls them objects, and allowing strings is only because of how JS works, correct? I think a more strict approach is better, but it raises the question again of whether a map in Ren should enforce name-value pairs or if it is really more of a "hinted list" which could also support construction syntax?
WiseGenius
@WiseGenius
Jun 18 2015 16:25
I think a map should be a map. Why do you consider it could be just a hinted list?
Gregg Irwin
@greggirwin
Jun 18 2015 16:27
If it was, then it could encompass Redbol construction syntax as well.
WiseGenius
@WiseGenius
Jun 18 2015 16:29
How do you mean?
Gregg Irwin
@greggirwin
Jun 18 2015 16:31
#[object! [a: 1]] would be valid, as in Rebol.
Though Red map uses #() instead of #[].
WiseGenius
@WiseGenius
Jun 18 2015 16:37
I think Rebol will soon follow.
WiseGenius
@WiseGenius
Jun 18 2015 16:43
red>> #(object! [a: 1])
== #(
    object!: [a: 1]
)
>> #[object! [a: 1]]
== make object! [
    a: 1
]
WiseGenius
@WiseGenius
Jun 18 2015 16:49
I think #(...) should always be for maps, and distinct from #[...]. And then the question becomes, “Should #[...] be construction syntax, or just a hinted list?” To which I would answer, “Let #[...] be a hinted list for now, if anything.”
Gregg Irwin
@greggirwin
Jun 18 2015 17:54
[] = list
() = list
#[] = hinted list
#() = map (also a hinted list)
?
Right now I just have list and map types in Ren, but it really just adds an opt # to the grammar and implementations can safely ignore it. What we have, then, is 4 types of lists, which are all lists, but are decorated to provide more meaning. So Redbol and Ren loaders can distinguish them, but the are all any-list! values.
Thoughts?
And does this align with #{} for binary values, in that they are a form of hinted string? And 1.#NaN/1.#INF in Red, which are hinted numbers?
Gregg Irwin
@greggirwin
Jun 18 2015 18:00
It does not align with issues, and may then lead to asking if hinted lists could support leading tags, like 64#{} does. Let's not go there yet though. :)