Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: a style question: |
| Date | 2015-09-02 19:37 +1200 |
| Message-ID | <d4nna9F2slhU4@mid.individual.net> (permalink) |
| References | (3 earlier) <d4josjFqhdfU8@mid.individual.net> <ms2do6$d72$1@dont-email.me> <d4jt2bFqhdfU9@mid.individual.net> <ms2hc5$smt$1@dont-email.me> <7fc815dc-1c69-4134-a32c-ad7e9364619e@googlegroups.com> |
Malcolm McLean wrote: > On Monday, August 31, 2015 at 10:38:05 PM UTC+1, Bart wrote: >> On 31/08/2015 21:51, Ian Collins wrote: >> >>> Do they? Mine certainly don't. Yes I have specialised numeric types >>> and associative arrays (JSON types) in my libraries, but they can't be >>> implemented without operator overloading. >> >> Numeric types are one of the very few examples where overloading might >> actually be needed. But I don't think it's a common enough general >> requirement. >> >> Associative arrays I don't know about; you mean just to overload "[]"? I >> would also consider that rare enough that it can be done with function >> calls. If you really need it with "[]", then it could be done partly >> behind the scenes with my #pragma method. It keeps the main language >> simple. /And/ stops people using such features inappropriately. >> > I've got a need for JSON in my program. > > So I've got a JParser class which you initialise with a JSON string, > then you call getReal(), getInteger(), getString() or getObject() > to query the structure. getObject() returns another JParser. > There's also something for arrays. Which is rather inelegant. Manipulating JSON objects is an ideal use for operator overloading. Using operator[] to access sub-objects makes JSON manipulation much cleaner and mode like JSON in its home language, JavaScript. > However that's only acceptable because our need is to get some JSON > (actually from a third party library called Sciter), pull out > known fields, then generate some JSON, almost always a fairly simple > structure, to send back. We don't need to pass JSON objects > about C++ functions and manipulate them. Once something like JSON objects is made simple and the design makes them light weight to pass around, they are a convenient container for heterogeneous data. If the interface is clunky, they won't find favour which is why I've not seen heterogeneous containers heavily used in C. I use JSON for most of my inter-process communication (especially when the other end is a web page!), so the objects tend to propagate through the code. -- Ian Collins
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
a style question: G G <gdotone@gmail.com> - 2015-08-31 02:30 -0700
Re: a style question: Ian Collins <ian-news@hotmail.com> - 2015-08-31 21:40 +1200
Re: a style question: jt@toerring.de (Jens Thoms Toerring) - 2015-08-31 09:52 +0000
Re: a style question: Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-31 03:24 -0700
Re: a style question: Bartc <bc@freeuk.com> - 2015-08-31 11:50 +0100
Re: a style question: Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-31 13:21 +0100
Re: a style question: Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-31 05:41 -0700
Re: a style question: Bartc <bc@freeuk.com> - 2015-08-31 14:55 +0100
Re: a style question: Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-31 15:50 +0100
Re: a style question: Bartc <bc@freeuk.com> - 2015-08-31 18:40 +0100
Re: a style question: Melzzzzz <mel@zzzzz.com> - 2015-08-31 17:46 +0200
Re: a style question: Bartc <bc@freeuk.com> - 2015-08-31 17:27 +0100
Re: a style question: Melzzzzz <mel@zzzzz.com> - 2015-08-31 18:42 +0200
Re: a style question: Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-08-31 17:41 +0000
Re: a style question: Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-31 15:33 -0700
Re: a style question: Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-09-01 08:34 +0000
Re: a style question: Ian Collins <ian-news@hotmail.com> - 2015-09-01 07:40 +1200
Re: a style question: Bartc <bc@freeuk.com> - 2015-08-31 21:36 +0100
Re: a style question: Ian Collins <ian-news@hotmail.com> - 2015-09-01 08:51 +1200
Re: a style question: Bartc <bc@freeuk.com> - 2015-08-31 22:37 +0100
Re: a style question: Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-31 15:24 -0700
Re: a style question: Ian Collins <ian-news@hotmail.com> - 2015-09-02 19:37 +1200
Re: a style question: jt@toerring.de (Jens Thoms Toerring) - 2015-08-31 23:33 +0000
Re: a style question: Bartc <bc@freeuk.com> - 2015-09-01 01:13 +0100
Re: a style question: Ian Collins <ian-news@hotmail.com> - 2015-09-01 18:21 +1200
Re: a style question: jt@toerring.de (Jens Thoms Toerring) - 2015-09-01 15:23 +0000
Re: a style question: Bartc <bc@freeuk.com> - 2015-09-01 18:06 +0100
Re: a style question: Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-09-01 20:39 +0000
Re: a style question: jt@toerring.de (Jens Thoms Toerring) - 2015-09-01 20:45 +0000
Re: a style question: Bartc <bc@freeuk.com> - 2015-09-01 22:53 +0100
Re: a style question: Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-31 17:51 -0700
csiph-web