On 2016-12-23 6:40 AM, Nicholas Nethercote wrote:
> It was once a mess, but is not any more. MFBT has for some time used
> standard Mozilla style, with the following minor exception described in
> mfbt/STYLE:
> 
> - Some of the files use a lower-case letter at the start of function names.
>   This is because MFBT used to use a different style, and was later
> converted
>   to standard Mozilla style. These functions have not been changed to use an
>   upper-case letter because it would cause a lot of churn in other parts of
> the
>   codebase. However, new files should follow standard Mozilla style and use
> an
>   upper-case letter at the start of function names.

Isn't mozilla::Result new code?

> - Imported third-party code (such as decimal/*, double-conversion/*, and
> lz4*)
>   remains in its original style.
> 
> On Fri, Dec 23, 2016 at 9:48 PM, Mike Hommey <m...@glandium.org> wrote:
> 
>> On Fri, Dec 23, 2016 at 12:07:28PM +0200, smaug wrote:
>>> On 12/20/2016 03:46 PM, Jan de Mooij wrote:
>>>> Hi all,
>>>>
>>>> A few weeks ago we added mozilla::Result<V, E> to MFBT [0][1]. I was
>> asked
>>>> to inform dev-platform about this, so here's a quick overview.
>>>> mozilla::Result<V, E> is based on Rust's Result type [2]. It contains
>>>> either a success value of type V or an error value of type E. For
>> example,
>>>> a function Foo that returns an `int` on success or some `Error` (enum,
>>>> pointer, etc) on failure, would have this signature:
>>>>
>>>>    Result<int, Error> Foo();
>>>>
>>>> mozilla::Ok is an empty struct that can be used when a function doesn't
>>>> return anything on success:
>>>>
>>>>    Result<Ok, Error> Bar() { ... return Ok(); }
>>>>
>>>> The MOZ_TRY(expr) macro is similar to Rust's try! macro: if `expr` is
>> an
>>>> error it propagates it to the caller, else it continues:
>>>>
>>>>    Result<V, E> Baz() { MOZ_TRY(Bar()); ... }
>>>>
>>>> There's also a MOZ_TRY_VAR macro that can be used when you want to
>> store
>>>> the return value on success. Result has isOk(), isErr(), unwrapOk(),
>>>> unwrapErr() methods that do what you'd expect. It also has the
>>>> MOZ_MUST_USE_TYPE annotation, so the static analysis builds will
>> complain
>>>> if you ignore the return value of a function that returns Result.
>>>>
>>> Why is the API not using Mozilla coding style with method naming?
>>> "In C/C++, method names should be capitalized and use CamelCase."
>>> Though, looks like MFBT is odd beast in coding style.
>>> Waiting for tools to just format everything to use same style.
>>
>> The question is asked very often, and the answer is MFBT was forked off
>> spidermonkey code, and spidermonkey has its own coding style.
>>
>> Yes, it's a mess.
>>
>> Mike
>> _______________________________________________
>> dev-platform mailing list
>> dev-platform@lists.mozilla.org
>> https://lists.mozilla.org/listinfo/dev-platform
>>
> _______________________________________________
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
> 

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to