- if cargo blocks - 8 Updates
- complains using void as template argument - 3 Updates
- Range-aware modulo operator -% - 7 Updates
Ralf Goertz <me@myprovider.invalid>: Jan 01 11:43AM +0100 Am Mon, 31 Dec 2018 11:50:39 -0700 > > there is no way you could use either construct in a German > > sentence. > Is 'Wo gehen Sie hin?' or splitting 'davon' acceptable? Okay, I didn't think about that (spitting). "Wo gehen Sie hin" is acceptable but "Wohin gehen Sie?" is slightly better imho. "Davon" like "dafür" should not be splitted I think. "Da habe ich genug von" is awkward. The only exception would be the very colloquial "Da nich(t) für" meaning "Don't mention it" as a reply after being thanked for something. But that deliberately plays with the awkwardness of the word order/splitting which is why one would also normally omit the t. > sure if it is acceptable current usage or just crime novel slang. > (Scandinavian crime novels usually are translated to German before > English, if they ever do get translated.) I'm not familiar with that particular genre but the word itself is just used to stress the fact that Swedish crime novels are often dark or deep and sometimes brutal. I think it's mainly used in marketing as some kind of seal of quality. |
Ralf Goertz <me@myprovider.invalid>: Jan 01 12:04PM +0100 Am Mon, 31 Dec 2018 18:09:51 +0100 > some of its own variations. In both German and Latin (AFAIK) > infinitives are formed by verb endings - there is no way to "split" > them. This may be the origin of the rule in English. Correct, German infinitives always end in -en with the (only?) exception of "sein" ("to be") and usually differ frome their inflections. But there is a language construct called (extended) infinitive with "zu" ("to"). With that the famous Star Strek slogan could be translated "(Sie zogen aus, um) mutig dahin /zu gehen/, wohin niemand jemals gegangen ist." The "zu" in that case is mandatory and there is no way you could ever put anything between "zu" and "gehen" let alone "mutig". On the other hand I would have considered "to boldly go" very good English a few days ago… |
Ralf Goertz <me@myprovider.invalid>: Jan 01 02:27PM +0100 Am Tue, 1 Jan 2019 11:43:51 +0100 > > Is 'Wo gehen Sie hin?' or splitting 'davon' acceptable? > Okay, I didn't think about that (spitting). "Wo gehen Sie hin" is > acceptable but "Wohin gehen Sie?" is slightly better imho. On second thought I doubt that this really is an example of splitting "wohin" but of "hingehen". It is not so obvious here because of the ambiguity. But when you say "Gehen Sie hin!" and the similar "Sie sollen hingehen!" there is no "wo" the "hin" could have been cut from (from which the "hin" could have been cut ;-)). Furthermore, according to the Duden neither "hin" nor "davon" are prepositions but adverbs. So I guess my initial assumption of no preposition in the end of a German sentence still holds. PS: I probably misread your entire post. Now I think you asked when (or whether at all) it is acceptable to split verbs in German. Short answer: as with the piling up of verbs in the end of a subordinate sentence or one that is in present or past perfect it is more common to have to split composite verbs. But not always. You say "Er /trennt/ die Briefmarke (vom Brief) /ab/" but "Er /durchtrennt/ die Stromleitungen"… |
gazelle@shell.xmission.com (Kenny McCormack): Jan 01 02:17PM In article <20190101142714.3ea5afa2@assi.fritz.box>, Ralf Goertz <me@myprovider.invalid> wrote: ... >one that is in present or past perfect it is more common to have to >split composite verbs. But not always. You say "Er /trennt/ die >Briefmarke (vom Brief) /ab/" but "Er /durchtrennt/ die Stromleitungen"… Subject line fixed. You may continue from here. Thank you. -- "Women should not be enlightened or educated in any way. They should be segregated because they are the cause of unholy erections in holy men. -- Saint Augustine (354-430) -- |
rbowman <bowman@montana.com>: Jan 01 10:57AM -0700 On 01/01/2019 03:43 AM, Ralf Goertz wrote: > used to stress the fact that Swedish crime novels are often dark or deep > and sometimes brutal. I think it's mainly used in marketing as some kind > of seal of quality. Some of the Swedish have become popular. Henning Mankel's 'Wallender' detective stories might have been the first. Stieg Larsson's Millenium series also became popular. The Swedes filmed all three books of the trilogy. The first, 'The Girl With the Dragon Tattoo' was redone in English but the other two never made it. A sequel that was written after Larsson died was filmed in English instead and just released. Åsa Larsson (no relation) has some books translated into English but they generally make it into German first. Thanks to Amazon they are available. If nothing else people in the US are getting more exposure to Europe rather than just the UK. 'Deutschland 83' was a joint production and was shown on US TV in German with subtitles. I think it was more popular in the US than in Germany. Perhaps the DDR and Stasi skeletons aren't buried deep enough yet. |
rbowman <bowman@montana.com>: Jan 01 11:04AM -0700 On 01/01/2019 06:27 AM, Ralf Goertz wrote: > one that is in present or past perfect it is more common to have to > split composite verbs. But not always. You say "Er /trennt/ die > Briefmarke (vom Brief) /ab/" but "Er /durchtrennt/ die Stromleitungen"… 'But not always' is the motto of English. I am glad I learned it from the cradle but even then some of the current common usage seems strange. I often hear 'Do you want to go with?' and wait for the rest of the sentence. |
Ralf Goertz <me@myprovider.invalid>: Jan 01 09:18PM +0100 Am Tue, 1 Jan 2019 10:57:07 -0700 > was shown on US TV in German with subtitles. I think it was more > popular in the US than in Germany. Perhaps the DDR and Stasi skeletons > aren't buried deep enough yet. Oh boy. We are really getting off topic here. But I need to respond to that. There are quite a few movies about the former DDR or the change its people had to undergo after the wall came down. "Sonnenallee" comes to mind for instance. I never watch them. I tried to watch "Deutschland 83" but I stopped after the first episode. Why? Because I don't need to. I think it's great that these movies/shows exist but I don't need to watch them, because I lived them. Let people outside Germany watch them and learn about the indoctrination that took place. (It always sends shivers down my spine to watch this North Korean News announcer [is it always the same woman?] when she is reports the great achievements of the ruling party or its leader. Of course, I don't understand anything and our cultures are very different but the way she talks reminds me of cult leaders [or Rick] and I have become very allergic to that.) The pretending that was necessary to survive (maybe not literally but at least socially) both amazes me (How can people do that?) and disgusts me (How could I have done it?). And I really don't want to be reminded of it so I am not particularly inclined to watch. I am so glad that that is over now. I don't know how many people here feel the same, but I wouldn't conclude from the fact that this show was a greater success in the US than in Germany that the skeletons aren't buried deep enough. I am much more concerned about the fact that the refugee crisis in 2015 flushed the scum back up that I had hoped to stay buried after WWII. Having an American president acting the way he does certainly doesn't help… |
rbowman <bowman@montana.com>: Jan 01 04:18PM -0700 On 01/01/2019 01:18 PM, Ralf Goertz wrote: > its people had to undergo after the wall came down. "Sonnenallee" comes > to mind for instance. I never watch them. I tried to watch "Deutschland > 83" but I stopped after the first episode. Why? Because I don't need to. Yeah, I'm an old fart and tend to wander. About time to get back to C. All I can say is very few lessons have been learned, at least in the US. |
anhongleetcode@gmail.com: Dec 31 08:44PM -0800 Hi Experts, I am new to the c++ language and I tried the following code. basically I have many different kind of requests and I would like to register a callback when the request get a response. sometimes the request doesn't ask for a response with information, then the res_t should be void. The following code complains I am using the void as template argument. someone suggests me to define another exactly same function, but take std::function<void()> as argument. I tried and succeeds. Is this the only way to get rid of this error? Can I just have one function request() body to take care of all thes void /non-void cases? Because for these two request() function I am just copying code. Thanks, Anhong /////// code struct req_1_t { using parms_t = struct { int id; std::string buf; }; using res_t = int; }; struct req_2_t { using parms_t = struct { int id; int value; }; using res_t = void; }; template<typename T> void request(typename T::parms_t /* parms_list */, std::function<void(typename T::res_t)> /* on_done */) {} // template<typename T> void request(typename T::parms_t parms_list, std::function<void()> on_done) // {} int main() { request<req_1_t>({}, [](int){}); request<req_2_t>({}, []( ){}); // error, complains using void as template argument return 0; } |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jan 01 06:40AM +0100 > request<req_2_t>({}, []( ){}); // error, complains using void as template argument > return 0; > } The syntax like int main( void ) is just a device used in C to indicate that a function does not have any arguments. It doesn't mean that there is an argument of type `void`. And it's a literal syntax, where the keyword `void` could just as well have been `__gah__` or say `noargs` or whatever, so you can't, say, define `using X = void;` and write `int main( X )`, just as you could not have defined `using X = __gah__;`, because `__gah__` isn't a type here. C++ supports the syntax for compatibility, but otherwise it's meaningless in C++, a pure C-ism, because (unlike in C) in C++ `int main()` states directly that the function has no arguments. So, that's why the code doesn't compile: there is just no such thing as an argument of type `void`. The C-ism syntax is just misleading. Though, for convenience, one /can/ do `return void()` for a function returning `void`, proving that ~nothing's free of special case rules in C++. Technically you can save the current code by, for example, introducing a traits template whose specializations map from `req_N_t::res_t` to some function type used for your callback argument. But I would work on the design instead of the coding. Because it sounds a bit fishy to me to have callbacks with different number of arguments. I'd work on unifying that. Cheers!, - Alf |
Sam <sam@email-scan.com>: Jan 01 08:48AM -0500 > template<typename T> void request(typename T::parms_t /* parms_list */, > std::function<void(typename T::res_t)> /* on_done */) > {} You have to use specialization to deal with this situation, with a helper template, something along the lines of: template<typename T> struct on_done_t { typedef std::function<void (T)> type; }; template<> struct on_done_t<void> { typedef std::function<void ()> type; }; template<typename T> void request(typename T::parms_t /* parms_list */, typename on_done_t<typename T::res_t>::type); |
Bart <bc@freeuk.com>: Dec 31 11:43PM On 31/12/2018 21:32, Rick C. Hodgin wrote: > x was assigned an address by the compiler to reference that data. Let > us suppose it was 0x123456. That means printf("0x%x\n"), _x) would print > out 0x123456. Isn't that what happens now with printing 'x'? >> In any case, C programs can use 'if (!!x)' for exactly this purpose. > Yeah, and I still don't know what that operator does. :-) not not. The first converts (-3, -2, -1, 0, 1, 2, 3) to (0, 0, 0, 1, 0, 0, 0). The second to (1, 1, 1, 0, 1, 1, 1). I think the > x? conveys information similar to what we see in assembly, with the > carry? flag, sign? flag, zero? flag, etc. It's actually where I got > that inspiration. If you write if(x), while(x), or for(;x;), then it automatically applies the effective equivalent of !! to give a true (x!=0) or false (x==0) result. (The same with (x && y) and any such combinations.) You don't need an explicit !! or ?. I don't see it being the same as carry and zero flags at all. Certainly not the zero flag, which does the opposite thing. > #define BSF(x) x?<< > #define BSR(x) >>?x > Done. Yes, you demonstrated this back-to-front thinking before. Tell me, what operator do you use to extract (or set) the nth bit of an integer value? /That/ would be more useful. > I suppose it could use: > {a /% b : divide_value, remainder}; The lldiv function in C returns a struct of two values. /% ought to also return two values, which could also be in the form of a struct, to avoid adding more features. > If you have a right and middle, it's: (|middle|right||) > If you have all three, it appears as: (||left|middle|right||) > It's very straight-forward, it's just not well known (yet). :-) I've always had a divrem operator, but have never implemented it. When I do, it will simply be like this: d := a divrem b # d:=a%b (% is integer division) d,r := a divrem b # d:=a%b, r:=a rem b At the moment it would need to be done like this via a function that returns both values: d := xdivrem(a,b) # ignore the second value d, r := xdivrem(a,b) so not inline. But notice I'm not bothered about having a symbol for the operator; and I use 'rem' for C's "%". Notice also I don't need 'casks'. -- bart |
Keith Thompson <kst-u@mib.org>: Dec 31 04:44PM -0800 Bart <bc@freeuk.com> writes: [...] > If you write if(x), while(x), or for(;x;), then it automatically applies > the effective equivalent of !! to give a true (x!=0) or false (x==0) > result. (The same with (x && y) and any such combinations.) [...] That's one way to describe it. It's now how the standard describes it. For example, the description of the "if" statement says "the first substatement is executed if the expression compares unequal to 0", which I find clearer and simpler than your reformulation. -- Keith Thompson (The_Other_Keith) kst@mib.org <http://www.ghoti.net/~kst> Will write code for food. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister" |
Bart <bc@freeuk.com>: Jan 01 01:06AM On 01/01/2019 00:44, Keith Thompson wrote: > For example, the description of the "if" statement says "the first > substatement is executed if the expression compares unequal to 0", > which I find clearer and simpler than your reformulation. That's the whole expression. It doesn't really explain how a complex expression ends up as zero or not zero. Or the difference between A && B when B is 'b==x' and when B is just 'b'. From a design and implementation point of view, you have to go into it in more detail. Perhaps simpler might be to say that operands of if(), while(), for(;;), &&, || unary !, need to be either already Bool, or have to be converted to Bool. It is that last that can also be done with !!. -- bart |
gazelle@shell.xmission.com (Kenny McCormack): Jan 01 01:53AM In article <lnd0phmcjw.fsf@kst-u.example.com>, >> result. (The same with (x && y) and any such combinations.) >[...] >That's one way to describe it. It's now how the standard describes it. That's good to know. I assume it used to describe it some other way, but it (the standard) has now seen the light of Bart's way. That's good. -- Faced with the choice between changing one's mind and proving that there is no need to do so, almost everyone gets busy on the proof. - John Kenneth Galbraith - |
Bart <bc@freeuk.com>: Dec 31 10:33PM On 31/12/2018 21:57, Richard Damon wrote: > C adds a 'shortcut' of p->m as the syntax sugar for (*p).m > Perhaps having the indirect operation being postfix instead of prefix > cleans up some issue with syntax, getting rid of some needs of parenthesis. That is the crucial part. It means pointers to arrays in C would have been more popular if accesses could be written A^[i] ('*' wouldn't work) instead of (*A)[i]. Pointers to struct members could be written consistently as P^.m instead of either (*P).m or P->m, while adding or removing an indirection is just adding or removing ^, instead of having to add or remove (*) or to transform between -> and (*) or between -> and . or between (*) and . And calls via function pointers could be consistently written F^(x) instead of (*F)(x) or via the confusing F(x). > having 2 notations doesn't seem that bad. > Rick's multitude of options seems much less useful, and I suspect he is > going to run into parsing issues with his grammar. Almost certainly. -- bart |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Dec 31 07:14PM -0800 On Monday, December 31, 2018 at 6:44:14 PM UTC-5, Bart wrote: > > us suppose it was 0x123456. That means printf("0x%x\n"), _x) would print > > out 0x123456. > Isn't that what happens now with printing 'x'? Yes, but the point is _x is a type unsigned int (either 32-bit or 64-bit depending on the side of the pointer). > > Yeah, and I still don't know what that operator does. :-) > not not. The first converts (-3, -2, -1, 0, 1, 2, 3) to (0, 0, 0, 1, 0, > 0, 0). The second to (1, 1, 1, 0, 1, 1, 1). Perfectly clear. Thank you. > the effective equivalent of !! to give a true (x!=0) or false (x==0) > result. (The same with (x && y) and any such combinations.) > You don't need an explicit !! or ?. It's useful for testing against a state, not merely against true or false. > > #define BSR(x) >>?x > > Done. > Yes, you demonstrated this back-to-front thinking before. We all have our opinions. :-) > Tell me, what operator do you use to extract (or set) the nth bit of an > integer value? /That/ would be more useful. Given the operation [x = (x >> shift) & mask] it seems clear the operator should be y >shift#msk>= x, doncha think? :-) And to set a value [x = (x & ~(mask << shift)) | (n << shift)] it seems clear the operator should be y &~<<m#s|#n<<= x, wouldn't you say? >n#m>= -- Get bits &~<<m#s|#n<<= -- Set bits Easy as cake, yes? :-) > The lldiv function in C returns a struct of two values. /% ought to also > return two values, which could also be in the form of a struct, to avoid > adding more features. IMO, certain classes of operations require their own distinct character of processing due to their nature. This type of div- ision + remainder is one of them. > so not inline. But notice I'm not bothered about having a symbol for the > operator; and I use 'rem' for C's "%". > Notice also I don't need 'casks'. I don't NEED casks either, but they are an integral component of computer programming. The introduce the ability to inject arbi- trary source code into the middle of an otherwise syntactically correct expression. It introduces the ability, for example, to use a <|logic|> cask to perform an operation based on the inter- mediate result of a logic test. if (x == 4 <|meta|some_code1()||>) // meta = run if true // Code here if (y == 3 <|mefa|some_code2()||>) // mefa = run if false // Code here The <|meta|> and <|mefa|> casks can be shorted to <|t|> and <|f|>, and they are logic casks, which run the code contained within if the condition matches. You can also do both conditions: if (x == 3 <||meta|if_true()|if_false()||>) // Code here It is similar to x ? y : z;, if x is true, then y, otherwise z. In this case <||x|y|z||>, or <||meta|y|z||>. It really is very logical. :-) -- Rick C. Hodgin |
Keith Thompson <kst-u@mib.org>: Dec 31 03:20PM -0800 > It isn't a 'real' NNTP newsgroup, just one of the pseudo newsgroups on, > if I remember right, googlegroups (so accessible on web through it as if > it was a newsgroup, but doesn't leave google). My point stands. -- Keith Thompson (The_Other_Keith) kst@mib.org <http://www.ghoti.net/~kst> Will write code for food. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister" |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment