[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: ["all"] as an Lvalue?
- From: Steve Litt <slitt@...>
- Date: Mon, 28 Mar 2016 22:19:28 -0400
On Tue, 29 Mar 2016 12:04:13 +1100
Daurnimator <quae@daurnimator.com> wrote:
> On 29 March 2016 at 11:55, Steve Litt <slitt@troubleshooters.com>
> wrote:
> > Hi all,
> >
> > I'm writing a document on Luakit, and in my section on making fonts
> > bigger, I need to give instructions to edit the domain_props table,
> > which looks something like this:
> >
> > =====================================================
> > domain_props = {
> > ["all"] = {
> > enable_scripts = false,
> > enable_plugins = false,
> > enable_private_browsing = false,
> > user_stylesheet_uri = "",
> > },
> > ["youtube.com"] = {
> > enable_scripts = true,
> > enable_plugins = true,
> > },
> > }
> > =====================================================
> >
> > It looks like domain_props is a table whose two elements are each
> > tables, named ["all"] and ["youtube.com"] respectively. I've never
> > seen something like ["all"] being the name of a table element or a
> > variable name before. What's going on, is ["all"] an anonymous
> > table containing element "all"? I just don't understand this
> > syntax, and why somebody would do this. What am I missing?
>
> { foo = "bar" }
> is actually just short for:
> { ["foo"] = "bar" }
>
> The first shorter form however only works for keys that are valid
> identifiers. Which means you have to use the 2nd form for:
> - keywords (e.g. {["end"] = 1234})
> - non-valid identifiers
> - e.g. starting with a number: {["1thing"] = item}
> - e.g. containing a ".": {["youtube.com"] = "a website"}
> - non-string keys. e.g. {[50] = "number as key"}
>
Thanks Coda, Jonathan and Daurnimator:
I'd seen that many times as states["florida"], but I'd never before
seen it as {["firstname"] = "steve"}. Now that you explained it, it
makes perfect sense and I got everything to work in Luakit.
Thanks!
SteveT
Steve Litt
March 2016 featured book: Quit Joblessness: Start Your Own Business
http://www.troubleshooters.com/startbiz