Re: Re: What do you think about a C# 6 like nameof() expression for
guest271314, what is you point against `nameof` feature? If you don't like it - don't use it. Why prohibit this feature for those who find it beneficial? I see `nameof` beneficial in following cases Case 1. Function guard. ``` function func1(options) { ... if (options.userName == undefined) { throw new ParamNullError(nameof options.userName); // `ParamNullError` is a custom error, derived from `Error`, composes error message like "Parameter cannot be null: userName". // `Object.keys({options.userName})[0]` will not work here } } ``` Case 2. Accessing property extended info Those ES functions that accept field name as string. e.g. ``` const descriptor1 = Object.getOwnPropertyDescriptor(object1, 'property1'); ``` vs ``` const descriptor1 = Object.getOwnPropertyDescriptor(object1, nameof object1.property1); // `Object.keys({options1.property1})[0]` will not work here ``` 2nd variant (proposed) has more chances not to be broken during refactoring (robustness). It would make devs who use IDE more productive and make their life easier. Why not give them such possiblity and make them happy? ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Re: What do you think about a C# 6 like nameof() expression for
> Is Case 1 equivalent to a briefer version of > ``` if (userName == undefined) { throw new Error(`Argument cannot be null: ${Object.keys({userName})[0]}`); } ``` Less readable but in this simple case might work. What if we do the following: Case 1. Function guard. ``` function func1(options) { ... if (options.userName == undefined) { throw new ParamNullError(nameof options.userName); // `ParamNullError` is a custom error, derived from `Error`, composes error message like "Argument cannot be null: userName". } } ``` Case 2. Accessing property extended info e.g. ``` const descriptor1 = Object.getOwnPropertyDescriptor(object1, 'property1'); ``` vs ``` const descriptor1 = Object.getOwnPropertyDescriptor(object1, nameof object1.property1); ``` 2nd variant (proposed) has more chances not to be broken during refactoring (robustness). On Fri, Jun 14, 2019 at 9:48 PM Stas Berkov wrote: > Less fragile. Less mess. You can rename field/property without fear you > break something (using IDE refactoring tools). > With high probablity you will break something when you refactor and have > fields hardcoded as strings. > Someone can object that you can rename strings as well. > Issue here that you can ocassionally change non-related strings that > should not be changed even they match or have matching substring. > > On Fri, Jun 14, 2019 at 9:38 PM guest271314 wrote: > >> Is Case 1 equivalent to a briefer version of >> >> ``` >>if (userName == undefined) { >>throw new Error(`Argument cannot be null: >> ${Object.keys({userName})[0]}`); >>} >> ``` >> >> ? >> >> If not, how is ```nameof``` different? >> >> What is the difference between the use of >> ```message.hasOwnProperty(property)``` >> and ```nameof msg.expiration_utc_time```? >> >> > You get more robust code. >> >> How is "robust" objectively determined? >> >> >> >> >> On Fri, Jun 14, 2019 at 5:21 PM Stas Berkov >> wrote: >> >>> ES can befit from `nameof` feature the same way as TS. There is no TS >>> specific in it. >>> It was ask to introduce in TS as a workaround since TS is considered as >>> extention of ES. >>> >>> Case 1. Function guard. >>> ``` >>> function func1(param1, param2, param3, userName, param4, param5) { >>>if (userName == undefined) { >>>throw new ArgumentNullError(nameof userName); // >>> `ArgumentNullError` is a custom error, derived from `Error`, composes error >>> message like "Argument cannot be null: userName". >>>} >>> } >>> ``` >>> >>> Case 2. Access extended information an object property. >>> Assume a function >>> ``` >>> function protoPropertyIsSet(message, property) { >>> return message != null && message.hasOwnProperty(property); >>> } >>> ``` >>> Then in code you use it as `if (protoPropertyIsSet(msg, >>> "expiration_utc_time")) {... }`. >>> Having `nameof` would allow you to do that `if (protoPropertyIsSet(msg, >>> nameof msg.expiration_utc_time)) {... }`. >>> You get more robust code. >>> >>> On Fri, Jun 14, 2019 at 5:46 PM Augusto Moura >>> wrote: >>> >>>> Can you list the benefits of having this operators? Maybe with example >>>> use cases >>>> >>>> If I understand it correctly, the operator fits better in compiled >>>> (and typed) languages, most of the use cases don't apply to dynamic >>>> Javascript >>>> The only legit use case I can think of is helping refactor tools to >>>> rename properties (but even mismatch errors between strings and >>>> properties names can be caught in compile time using modern >>>> Typescript) >>>> >>>> Em sex, 14 de jun de 2019 às 10:05, Stas Berkov >>>> escreveu: >>>> > >>>> > Can we revisit this issue? >>>> > >>>> > >>>> > In C# there is `nameof`, in Swift you can do the same by calling >>>> > >>>> > ``` >>>> > >>>> > let keyPath = \Person.mother.firstName >>>> > >>>> > NSPredicate(format: "%K == %@", keyPath, "Andrew") >>>> > >>>> > ``` >>>> > >>>> > Let's introduce `nameof` in ES, please. >>>> > >>>> > >>>> > Devs from TypeScrip
Re: Re: What do you think about a C# 6 like nameof() expression for
Less fragile. Less mess. You can rename field/property without fear you break something (using IDE refactoring tools). With high probablity you will break something when you refactor and have fields hardcoded as strings. Someone can object that you can rename strings as well. Issue here that you can ocassionally change non-related strings that should not be changed even they match or have matching substring. On Fri, Jun 14, 2019 at 9:38 PM guest271314 wrote: > Is Case 1 equivalent to a briefer version of > > ``` >if (userName == undefined) { >throw new Error(`Argument cannot be null: > ${Object.keys({userName})[0]}`); >} > ``` > > ? > > If not, how is ```nameof``` different? > > What is the difference between the use of > ```message.hasOwnProperty(property)``` > and ```nameof msg.expiration_utc_time```? > > > You get more robust code. > > How is "robust" objectively determined? > > > > > On Fri, Jun 14, 2019 at 5:21 PM Stas Berkov wrote: > >> ES can befit from `nameof` feature the same way as TS. There is no TS >> specific in it. >> It was ask to introduce in TS as a workaround since TS is considered as >> extention of ES. >> >> Case 1. Function guard. >> ``` >> function func1(param1, param2, param3, userName, param4, param5) { >>if (userName == undefined) { >>throw new ArgumentNullError(nameof userName); // >> `ArgumentNullError` is a custom error, derived from `Error`, composes error >> message like "Argument cannot be null: userName". >>} >> } >> ``` >> >> Case 2. Access extended information an object property. >> Assume a function >> ``` >> function protoPropertyIsSet(message, property) { >> return message != null && message.hasOwnProperty(property); >> } >> ``` >> Then in code you use it as `if (protoPropertyIsSet(msg, >> "expiration_utc_time")) {... }`. >> Having `nameof` would allow you to do that `if (protoPropertyIsSet(msg, >> nameof msg.expiration_utc_time)) {... }`. >> You get more robust code. >> >> On Fri, Jun 14, 2019 at 5:46 PM Augusto Moura >> wrote: >> >>> Can you list the benefits of having this operators? Maybe with example >>> use cases >>> >>> If I understand it correctly, the operator fits better in compiled >>> (and typed) languages, most of the use cases don't apply to dynamic >>> Javascript >>> The only legit use case I can think of is helping refactor tools to >>> rename properties (but even mismatch errors between strings and >>> properties names can be caught in compile time using modern >>> Typescript) >>> >>> Em sex, 14 de jun de 2019 às 10:05, Stas Berkov >>> escreveu: >>> > >>> > Can we revisit this issue? >>> > >>> > >>> > In C# there is `nameof`, in Swift you can do the same by calling >>> > >>> > ``` >>> > >>> > let keyPath = \Person.mother.firstName >>> > >>> > NSPredicate(format: "%K == %@", keyPath, "Andrew") >>> > >>> > ``` >>> > >>> > Let's introduce `nameof` in ES, please. >>> > >>> > >>> > Devs from TypeScript don't want to introduce this feature in >>> TypeScript unless it is available in ES ( >>> https://github.com/microsoft/TypeScript/issues/1579 ) >>> > >>> > This feature is eagarly being asked by TypeScript community. >>> > >>> > >>> > I understand there are couple issues related to `nameof` feature in >>> ES. They are: minification and what to do if user already has `nameof` >>> function. >>> > >>> > >>> > Minification. >>> > >>> > 1. If your code to be minimized be prepared that variable names will >>> also change. >>> > >>> > 2. (just a possibility) Minimizer can have option to replace >>> `nameof(someVar)` with result of `nameof` function. >>> > >>> > >>> > >>> > What if user already has `nameof` function. >>> > >>> > 1. To maintain status quo we can user `nameof` function having >>> priority over newly introduced language feature. >>> > >>> > 2. OR we can use `typeof` syntax, e.g. `nameof msg.userName` (// >>> returns "userName" string) >>> > >>> > ___ >>> > es-discuss mailing list >>> > es-discuss@mozilla.org >>> > https://mail.mozilla.org/listinfo/es-discuss >>> >>> >>> >>> -- >>> Atenciosamente, >>> >>> Augusto Borges de Moura >>> >> ___ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> > ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Re: What do you think about a C# 6 like nameof() expression for
ES can befit from `nameof` feature the same way as TS. There is no TS specific in it. It was ask to introduce in TS as a workaround since TS is considered as extention of ES. Case 1. Function guard. ``` function func1(param1, param2, param3, userName, param4, param5) { if (userName == undefined) { throw new ArgumentNullError(nameof userName); // `ArgumentNullError` is a custom error, derived from `Error`, composes error message like "Argument cannot be null: userName". } } ``` Case 2. Access extended information an object property. Assume a function ``` function protoPropertyIsSet(message, property) { return message != null && message.hasOwnProperty(property); } ``` Then in code you use it as `if (protoPropertyIsSet(msg, "expiration_utc_time")) {... }`. Having `nameof` would allow you to do that `if (protoPropertyIsSet(msg, nameof msg.expiration_utc_time)) {... }`. You get more robust code. On Fri, Jun 14, 2019 at 5:46 PM Augusto Moura wrote: > Can you list the benefits of having this operators? Maybe with example use > cases > > If I understand it correctly, the operator fits better in compiled > (and typed) languages, most of the use cases don't apply to dynamic > Javascript > The only legit use case I can think of is helping refactor tools to > rename properties (but even mismatch errors between strings and > properties names can be caught in compile time using modern > Typescript) > > Em sex, 14 de jun de 2019 às 10:05, Stas Berkov > escreveu: > > > > Can we revisit this issue? > > > > > > In C# there is `nameof`, in Swift you can do the same by calling > > > > ``` > > > > let keyPath = \Person.mother.firstName > > > > NSPredicate(format: "%K == %@", keyPath, "Andrew") > > > > ``` > > > > Let's introduce `nameof` in ES, please. > > > > > > Devs from TypeScript don't want to introduce this feature in TypeScript > unless it is available in ES ( > https://github.com/microsoft/TypeScript/issues/1579 ) > > > > This feature is eagarly being asked by TypeScript community. > > > > > > I understand there are couple issues related to `nameof` feature in ES. > They are: minification and what to do if user already has `nameof` function. > > > > > > Minification. > > > > 1. If your code to be minimized be prepared that variable names will > also change. > > > > 2. (just a possibility) Minimizer can have option to replace > `nameof(someVar)` with result of `nameof` function. > > > > > > > > What if user already has `nameof` function. > > > > 1. To maintain status quo we can user `nameof` function having priority > over newly introduced language feature. > > > > 2. OR we can use `typeof` syntax, e.g. `nameof msg.userName` (// returns > "userName" string) > > > > ___ > > es-discuss mailing list > > es-discuss@mozilla.org > > https://mail.mozilla.org/listinfo/es-discuss > > > > -- > Atenciosamente, > > Augusto Borges de Moura > ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Re: What do you think about a C# 6 like nameof() expression for
Can we revisit this issue? In C# there is `nameof`, in Swift you can do the same by calling ``` let keyPath = \Person.mother.firstName NSPredicate(format: "%K == %@", keyPath, "Andrew") ``` Let's introduce `nameof` in ES, please. Devs from TypeScript don't want to introduce this feature in TypeScript unless it is available in ES ( https://github.com/microsoft/TypeScript/issues/1579 ) This feature is eagarly being asked by TypeScript community. I understand there are couple issues related to `nameof` feature in ES. They are: minification and what to do if user already has `nameof` function. Minification. 1. If your code to be minimized be prepared that variable names will also change. 2. (just a possibility) Minimizer can have option to replace `nameof(someVar)` with result of `nameof` function. What if user already has `nameof` function. 1. To maintain status quo we can user `nameof` function having priority over newly introduced language feature. 2. OR we can use `typeof` syntax, e.g. `nameof msg.userName` (// returns "userName" string) ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
[AngularJS] Re: [angular.js] Re: Save Angular View as HTML file
And how to save computed CSS styles? document.html() will give you just html, computed CSS styles will be lost. On Wednesday, April 25, 2012 8:50:54 AM UTC+4, Misko Hevery wrote: We have not done this, but if you feel up to it here is what you can try 1. get node.js running 2. install of the many DOM implementations for node 3. Get your angular page running inside the node.js. 4. Get a hold of the $browser service and call notifyWhenNoOutstandingRequests() this will tell you when the page finished rendering 5. Do document.html() to get rendered HTML 6. send it to the crawler This is a lot more complicated then it seems, and I am sure you will run into many issues, but it should work in theory. :-) Good luck, and do report back. -- Misko On Tue, Apr 24, 2012 at 7:21 PM, Johan johan.s...@gmail.com javascript: wrote: See this post: https://groups.google.com/forum/#!topic/angular/C3LFZYaGQqo On Wednesday, April 25, 2012 6:24:05 AM UTC+12, Harlley Oliveira wrote: Hi, Is it possible to save a HTML DOM rendered by Angular to a local HTML file? Harlley Oliveira -- You received this message because you are subscribed to the Google Groups AngularJS group. To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/8P2Jy1dBHQMJ. To post to this group, send email to ang...@googlegroups.comjavascript: . To unsubscribe from this group, send email to angular+u...@googlegroups.com javascript:. For more options, visit this group at http://groups.google.com/group/angular?hl=en. -- You received this message because you are subscribed to the Google Groups AngularJS group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
[protobuf] repeated field naming style: singular or plural
Hi, when I use 'repeated' keyword in protobuf messages what form should I use: plural or singular? E.g. I have message message RealTimeMarketData { // client side subscription identifier required int32 Id = 1; // contract ID assigned by server required int32 contractId = 2; // new contract meta-data in case of active contract rolling // (subscribed symbol is now resolved to a new contract) optional ContractMetadata contractMetadata = 3; // Contract quotes. DOM is updated by new volumes per price. zero volume is used to clean this price record from DOM repeated Quote quote = 4; } *How should I spell repeated Quote quote = 4;'? Should it be quotes or quote? (plural or singular?)* If I choose repeated Quote quote it is confusing for Javascript and CSharp clients e.g. instrument.applyQuotes(realTimeMarketData.quote); - for method that accepts collection of quotes we pass single quote (that is how it looks). If I choose repeated Quote quotes then in c++ I get code like this: Quote* pQuote = message.add_Quotes(); - while I am adding single quote. Thanks, Stas -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/groups/opt_out.