Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
EnTerr
Roku Guru

Request: allow {"": x, "hyphen-ated": y, ".sub": z} literals

My request is simple, it fits the 60-char limit of the subject line. But in more words: please extend the implementation of hash-dictionary literals, so that string literals can be used as key names, besides identifiers. ... and it wouldn't even require documentation change, since it is mum on what is allowed as key in AA literal. 8-)

If we get BNF-y and say interpreter allows for
HashLiteral = '{' KeyValPair  (PairSeparator KeyValPair)* PairSeparator? '}'
PairSeparator = (',' | '\n') '\n'*
KeyValPair = IDENT ':' Expression

(* then change previous to *)
KeyValPair = (IDENT | STRLIT) ':' Expression

That was awfully formal. I think better will be to show requested feature in illustrative example, so here:

myForm = {
"": "form"
action: "/search/ccc"
method: "get"
"accept-charset": "utf-8"
id: "searchform"
".nodes": [
{ "": "input",
id: "query",
name: "query",
"data-suggest": "search",
autocorrect: "off",
placeholder: "search"
}
]
}
0 Kudos
5 REPLIES 5
TheEndless
Channel Surfer

Re: Request: allow {"": x, "hyphen-ated": y, ".sub": z} lite

You can use string literals as keys, just not inline like you've demonstrated. Something like this will work just fine:
myForm[".nodes"] = {}
myForm[".nodes"]["data-suggest"] = "search"
myForm[".nodes"]["A full sentence fragment with spaces and punctuation."] = "test"
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
EnTerr
Roku Guru

Re: Request: allow {"": x, "hyphen-ated": y, ".sub": z} lite

"TheEndless" wrote:
You can use string literals as keys, just not inline like you've demonstrated.
I know. But that's besides the point / not what i asked.
To me it seemed what i said was absolutely clear, considering subject line and example. I re-read what i wrote and while there is no technical mistake, I guess you missed the "extend the implementation of hash-dictionary literals" part, so i just highlighted it - hope that helps.

Bonus read: http://sdkdocs.roku.com/display/sdkdoc/ ... sConstants discusses what literals in BrSc are ("string literal", ["array", "literal"], {AA: "literal"} etc)
0 Kudos
RokuJoel
Binge Watcher

Re: Request: allow {"": x, "hyphen-ated": y, ".sub": z} lite

Write a more detailed explanation of what it is you are asking. If the most experienced Brightscript developer on planet earth, (I'm not exaggerating) didn't understand it, then you need to be a little more verbose in your writing.

I think you are asking to use quoted strings as the keys in an Associative Array, i.e.

aa={"key":value}

?

Also, please endeavor to be more respectful in your tone when posting on the forum, this is your 2nd warning, there won't be a third.

- Joel
0 Kudos
EnTerr
Roku Guru

Re: Request: allow {"": x, "hyphen-ated": y, ".sub": z} lite

"RokuJoel" wrote:
Write a more detailed explanation of what it is you are asking. If the most experienced Brightscript developer on planet earth, (I'm not exaggerating) didn't understand it, then you need to be a little more verbose in your writing.

I think you are asking to use quoted strings as the keys in an Associative Array, i.e.
aa={"key":value}
?

Also, please endeavor to be more respectful in your tone when posting on the forum, this is your 2nd warning, there won't be a third.

- Joel

Sorry Joel - but what are you objecting about my tone above? Be specific, please.
I did not criticize TheEndless (nor does he need introduction... but if he ever needed one, here is praise from me viewtopic.php?f=28&t=64546&p=450261&hilit=TheEndless#p450261 ).

Yes, that's what i was asking about - {"key": value}. Perhaps i was too technical by showing BNF. Sorry if i overshot with jargon - that part implied understanding theory of parsing/compiler construction. Do tell where i did wrong and i will re-work.

TheEndless - if i offended you, let me know?
Now I wonder - was i unclear or were you asking what my motivation was, of using {".nodes": ...} literals vs building data step by step?
0 Kudos
TheEndless
Channel Surfer

Re: Request: allow {"": x, "hyphen-ated": y, ".sub": z} lite

"EnTerr" wrote:
TheEndless - if i offended you, let me know?
Now I wonder - was i unclear or were you asking what my motivation was, of using {".nodes": ...} literals vs building data step by step?

No worries here. I misinterpreted "string literals" as meaning just that. I wasn't sure if you were asking for the ability to do it inline specifically, or if you didn't realize there were no limits to what you could actually use as a key.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.