Subject: Re: [Boost-docs] [Gaea] Named optional attributes
From: Joel de Guzman (joel_at_[hidden])
Date: 2011-11-01 10:22:53
On 11/1/2011 5:50 PM, Matias Capeletto wrote:
> One thing that I forget to add in my last mail was the possibility to
> give a default value to the optional arguments. If not included, the
> default value is nil '[]' so we can check for that to see if it was
> defined.
> The specs could easily be extended:
>
> [def [$ path ~width ~height] ... ]
>
> or
>
> [def [$ path [~width 100px] [~height 100px]] ... ]
>
> I know it is only syntax sugar because you could get the same effect
> checking for nil in the body but I think this will be a common
> scenario that is good we support right away.
Actually, I thought about that, wrote its spec just like you
did, but later came to the opposite conclusion as you have.
Do you really think that this is a common scenario? In the case
of the images, for example, a default does not make sense.
What other use cases do you think will this make sense?
Is it really that common?
Also, that would prevent us from detecting if the user did
pass something or not because there will always be a value
instead of an /optional/ value. Not sure if that matters
though.
I don't have a strong opinion on this. Your thoughts?
>> I modified the optional argument proposal a bit using tilde '~'
>> instead of dot '.' for named optional args. I want to use the
>> '.' for scoping.
>
> It looks good.
>
>> The later part of the spec discusses namespaces and scopes.
>
> Can you explain this a little bit more?
>
> ""
> You may import names from other scopes this way:
>
> [import [ns][foo][bar]] [/ Import foo and bar from ns ]"
> ""
>
> Is import defined like [def [import ns . symbols] ... ] ?
Yes.
(BTW, when discussing API, you can use decl:
[decl [import ns . symbols]]
So you don't have to have the ... body :-)
> Visually, I do not like that the three symbols are in the same level.
> Maybe is just aesthetics but I think I prefer something like
>
> [import ns.foo]
> [import ns.bar]
Just like C++ using. OK. No problem.
Regards,
-- Joel de Guzman http://www.boostpro.com http://boost-spirit.com
This archive was generated by hypermail 2.1.7 : 2017-11-11 08:50:41 UTC