Coding: Fleeting Thoughts

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
ahammel
My Little Cabbage
Posts: 2135
Joined: Mon Jan 30, 2012 12:46 am UTC
Location: Vancouver BC
Contact:

Re: Coding: Fleeting Thoughts

Postby ahammel » Mon Mar 07, 2016 9:49 pm UTC

One of the many, many things I will never forgive Atlassian for is inventing their own crappy markup language to compete with the several markup languages I already have to carry around in my head.
He/Him/His/Alex
God damn these electric sex pants!

User avatar
Wildcard
Candlestick!
Posts: 251
Joined: Wed Jul 02, 2008 12:42 am UTC
Location: Outside of the box

Re: Coding: Fleeting Thoughts

Postby Wildcard » Tue Mar 08, 2016 6:28 am UTC

ahammel wrote:One of the many, many things I will never forgive Atlassian for is inventing their own crappy markup language to compete with the several markup languages I already have to carry around in my head.

Oh, ugh. JIRA "markdown." Amen.

Here's a start....

Code: Select all

ex -sc '%s,^### ,h3. , | %s,^## ,h2. , | %s,^# ,h1. , | x' filename
There's no such thing as a funny sig.

User avatar
phlip
Restorer of Worlds
Posts: 7543
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Coding: Fleeting Thoughts

Postby phlip » Tue Mar 08, 2016 9:17 am UTC

Had a weird glitch today, did a Google search to see if anyone else was having it...

Found 3 results... all of them were the same guy, back in 2012, asking in a bunch of different places, and in all of them getting told to ask elsewhere instead.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
Yakk
Poster with most posts but no title.
Posts: 11045
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Tue Mar 08, 2016 10:07 am UTC

Did you try asking somewhere else?
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
Wildcard
Candlestick!
Posts: 251
Joined: Wed Jul 02, 2008 12:42 am UTC
Location: Outside of the box

Re: Coding: Fleeting Thoughts

Postby Wildcard » Wed Mar 09, 2016 2:41 am UTC

phlip wrote:Had a weird glitch today, did a Google search to see if anyone else was having it...

Found 3 results... all of them were the same guy, back in 2012, asking in a bunch of different places, and in all of them getting told to ask elsewhere instead.

Obligatory link.

Thank goodness today we have Stack Overflow, thus rendering the mouseover text of that comic obsolete. ;)
There's no such thing as a funny sig.

User avatar
You, sir, name?
Posts: 6974
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Sun Mar 13, 2016 8:40 pm UTC

I've been dicking around with machine learning. It's a lot of fun and surprisingly accessibleif you have a decent grasp of vector calculus.

--edit-- (on a somewhat related matter)

Never change, C++

Code: Select all

In instantiation of ‘typename MultiplyCompatible<A, B>::ReturnType operator*(A, B) [with A = HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<HorizVectorView<TransposedView<Matrix<3, 1, int>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>&>; B = VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<VertVectorView<Matrix<3, 1, int> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >; <template-parameter-1-3> = void; typename MultiplyCompatible<A, B>::ReturnType = Matrix<1, 1, int>]’:
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
Dinosaur!
Posts: 30
Joined: Fri Dec 14, 2012 8:45 pm UTC
Location: Santa Cruz, CA

Re: Coding: Fleeting Thoughts

Postby Dinosaur! » Wed Mar 16, 2016 7:46 am UTC

@ysn, what the shit is that monstrosity?!

User avatar
You, sir, name?
Posts: 6974
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Wed Mar 16, 2016 11:31 am UTC

It's a linear algebra/matrix library I built as a template metaprogramming experiment. The upside is that it's surprisingly competent and allows very expressive matrix programming, like

Spoiler:

Code: Select all

Matrix<3,3,int> a = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; // identity matrix
Matrix<3,1,int> b = { 4, 5, 6 }; // vertical matrix

col(a, 0) = b;

// a is now
// 4, 0, 0
// 5, 1, 0
// 6, 0, 1

row(a, 1) = transpose(b); // or if you prefer: transpose(row(a,1)) = b;

// a is now
// 4, 0, 0
// 4, 5, 6
// 6, 0, 1


The downside is that occasionally the type system explodes in fire and mayhem. Usually it catches it and bails out when the types get too deeply nested. Other times it gives you weird errors like the one in my previous posts (and the compilation log goes on and on about it, possibly hundreds of megabytes of errors). In rarer cases, it keeps on allocating memory until it runs out and the kernel slays the process.

--edit-- rofl

Code: Select all

$ g++ main.cpp  -std=c++14 2>/tmp/log
(^C after a few seconds)
$ wc -l /tmp/log
366 /tmp/log
$ du -hcs /tmp/log
1,1G    /tmp/log
1,1G    total
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
3fj
Posts: 1715
Joined: Wed Jun 11, 2008 1:13 pm UTC
Location: Land of Whisky and Bagpipes (LOWAB)
Contact:

Re: Coding: Fleeting Thoughts

Postby 3fj » Wed Mar 16, 2016 2:41 pm UTC

ucim wrote:
Thesh wrote:The language is C#.

What does C# do in a foreach when fed a non-array to loop through?


Way late to this party, but in C# foreach demands that the object you pass in is IEnumerable (that is, it must be made up of elements that can be iterated over and the contents only appear once. e.g. List, Dictionary, etc.) What you're suggesting isn't something that shouldn't be able to happen.

I've no idea what happens if you feed in an object that doesn't implement IEnumerable you managed to get into that state using dynamic. Please don't use dynamic unless you know exactly what it's doing under the hood. It gives the weirdest errors, and it might as well be shorthand for "please quadruple the runtime and memory requirements for my program".

Even in some hypothetical where result is dynamic the defensive code could be replaced with:

Code: Select all

if(result is IEnumerable)
{
    foreach(var foo in result)
    {
        //Stuff And Things
    }
}


ahammel wrote:One of the many, many things I will never forgive Atlassian for is inventing their own crappy markup language to compete with the several markup languages I already have to carry around in my head.


I wish I could be angrier about that, but my office is now in pretty deep with the Atlassian stack, and now we're dabbling with tools like Remark for our weekly tech presentations and Gauge to put a friendly face on our UI tests.
Everything's dead until it's alive. Man will exist, and then he will die. Just take the ride!

User avatar
Flumble
Yes Man
Posts: 1944
Joined: Sun Aug 05, 2012 9:35 pm UTC

Re: Coding: Fleeting Thoughts

Postby Flumble » Sat Mar 26, 2016 9:44 pm UTC

So there's this idea I have about tying chats/media shares like telegram, IRC and WhatsApp (using yowsup) together, but I'm unsure as to what common backend to use. The goal is to have all messages available to any networked device, though preferably messages would be loaded on demand, like a typical client does. (naturally through a secure channel and without sharing the plaintexts with a third party)
Should I just throw it all in a database and worry about accessing the messages and getting notifications later?
Should I pass it to a local IRC server and connect to that server to have a basic client and notification system? (and just download all the media to some directory and worry about that later)
Should I turn it into XMPP messages (or another open protocol) and find a suitable server and client to relay the messages?

Does it even matter which one I choose?
Should I even ask it in fleeting thoughts rather than StackOverflow?

User avatar
Xanthir
My HERO!!!
Posts: 5213
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Sun Mar 27, 2016 3:27 pm UTC

Whatever you feel most comfortable with would be my first instinct. You can always throw it all out and start again later if it was a bad choice.

Unrelated: Been reading the Haskell wikibook, and it's written *really well*. At least the "Advanced Haskell" chapters I've been reading are - they explain all the basic typeclasses *super well*, from multiple angles and with lots of examples. I got a much better intuition for Foldable and Traversable than I had before, and even the Applicative chapter was fun to read.
Last edited by Xanthir on Mon Mar 28, 2016 3:36 am UTC, edited 1 time in total.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
headprogrammingczar
Posts: 3072
Joined: Mon Oct 22, 2007 5:28 pm UTC
Location: Beaming you up

Re: Coding: Fleeting Thoughts

Postby headprogrammingczar » Sun Mar 27, 2016 11:29 pm UTC

It was a bit of a mess when I was learning, but it seems to have been much improved. The CPS page seems to still need work though...

FYI, not sure if it was phpbb or yourself but the trailing slash in your link makes the link bad.

Flumble, I would suggest a database might be the best suited to storing the richest form of each message no matter where it comes from. If you find that feature matters, of course.
<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Weeks> You're the goddamn headprogrammingspock!
<Cheese> I love you

User avatar
jestingrabbit
Factoids are just Datas that haven't grown up yet
Posts: 5963
Joined: Tue Nov 28, 2006 9:50 pm UTC
Location: Sydney

Re: Coding: Fleeting Thoughts

Postby jestingrabbit » Mon Mar 28, 2016 1:06 pm UTC

Does anyone know of a good guide for using ajax on rails that doesn't have all the client side code written in coffeescript? All the docs, naturally enough, use coffeescript...
ameretrifle wrote:Magic space feudalism is therefore a viable idea.

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5086
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Mon Mar 28, 2016 7:08 pm UTC

Code: Select all

FunkField ff = default(FunkField);
Action<FuncField> ffAction = delegate(FunkField x)
{
    ff = x;
}

if(IsTheRightFunkField(fieldNumber, index, ffAction))
{
    SomeObject foo = new SomeObject();
    //Initialize some other fields
    foo.Property = ff.Property;
}


I tried to condense this a bit and omit the unecessary stuff.

So you might be thinking to yourself... why wouldn't I just say, return the value? Rather than use a lambda to capture a local variable? Rather than call the lambda to set the variable in a called function?

I DO NOT KNOW.

Why did I look at this code to try and figure out why it was running so slow? IT WILL HAUNT MY DREAMS FOREVER NOW.


EDIT: OH NO IT GETS WORSE

Code: Select all

if(actionDel != null) actionDel(x);
{
    match = true;
}

This is verbatim, I have not changed indentation.

WHO NEEDS READABILITY ANYWAY?

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5086
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Mon Mar 28, 2016 7:42 pm UTC

Making it a dictionary and using TryGet sped it up by only a few orders of magnitude (well, I assume, I let it run for an hour when I went to lunch and it hadn't completed yet).

Now it's essentially instant. So there's a thing. :shock:

EDIT:

Actually, this is apparently only one of two issues causing extreme slowness during the scenario I'm testing (the other is... apparently... intermittent).

It's only Monday too, fuck this week.

User avatar
PM 2Ring
Posts: 3619
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Mid north coast, NSW, Australia

Re: Coding: Fleeting Thoughts

Postby PM 2Ring » Tue Mar 29, 2016 12:40 am UTC

Flumble wrote:So there's this idea I have about tying chats/media shares like telegram, IRC and WhatsApp (using yowsup) together, but I'm unsure as to what common backend to use. The goal is to have all messages available to any networked device, though preferably messages would be loaded on demand, like a typical client does. (naturally through a secure channel and without sharing the plaintexts with a third party)
Should I just throw it all in a database and worry about accessing the messages and getting notifications later?
Should I pass it to a local IRC server and connect to that server to have a basic client and notification system? (and just download all the media to some directory and worry about that later)
Should I turn it into XMPP messages (or another open protocol) and find a suitable server and client to relay the messages?

Does it even matter which one I choose?
Should I even ask it in fleeting thoughts rather than StackOverflow?


Definitely don't ask about that on StackOverflow: it would get put on hold as way too broad.

Sorry, I don't know enough about the problem domain to offer concrete advice, but I suggest that the message gathering, the message storage, and the message presentation phases should be as independent of each other as is practical.

User avatar
You, sir, name?
Posts: 6974
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Tue Mar 29, 2016 8:05 am UTC

When you don't know how to approach designing something, just be empirical about it. MacGyver a prototype and see if it works. If it does work, clean the design up and use it. If it doesn't, discard it and build something new that from what you learned. Rinse and repeat.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
Xenomortis
Not actually a special flower.
Posts: 1397
Joined: Thu Oct 11, 2012 8:47 am UTC

Re: Coding: Fleeting Thoughts

Postby Xenomortis » Wed Mar 30, 2016 10:01 am UTC

Today marks the first time that looking at java bytecode helped me solve a problem.
And extends keyword considered harmful.
Image

User avatar
Diadem
Posts: 5649
Joined: Wed Jun 11, 2008 11:03 am UTC
Location: The Netherlands

Re: Coding: Fleeting Thoughts

Postby Diadem » Wed Mar 30, 2016 4:59 pm UTC

I am increasingly convinced that the designers of Matlab / Simulink weren't just incompetent, but deliberately evil.

Who the fuck makes a language where the return type of many standard functions depends on the output, so that to do anything with the output you have to fill your program with dozens of if's and special cases. It's such an absurd design decision.

Example: You want to get a list of positions of ports on a Simulink block. Great. Get a list of ports, then get the position parameter for these ports. Easy. Matlab returns a cell array containing length-2 arrays. One set of coordinates for each port, exactly what you'd expect. EXCEPT that if there's only one port, then it returns an ordinary array containing the two coordinates.

Treat the resulting object as a cell array? Matlab crashes if there's only one port.
Treat the resulting object as an ordinary array? Matlab crashes if there's more than one port.

*sigh*
It's one of those irregular verbs, isn't it? I have an independent mind, you are an eccentric, he is round the twist
- Bernard Woolley in Yes, Prime Minister

korona
Posts: 495
Joined: Sun Jul 04, 2010 8:40 pm UTC

Re: Coding: Fleeting Thoughts

Postby korona » Wed Mar 30, 2016 9:52 pm UTC

Xenomortis wrote:Today marks the first time that looking at java bytecode helped me solve a problem.
And extends keyword considered harmful.

Could you elaborate?

User avatar
Xenomortis
Not actually a special flower.
Posts: 1397
Joined: Thu Oct 11, 2012 8:47 am UTC

Re: Coding: Fleeting Thoughts

Postby Xenomortis » Wed Mar 30, 2016 10:09 pm UTC

We had some code that extended a class from a third party library.
JAR is updated, API slightly changes, brittle code breaks.

Specifically, it overloaded a protected method that happened to be called in the base class' constructor to initialize some stuff, but after the update a different method (or rather, a different overload) was called, so this stuff was left uninitialized.
I only had to read a little bit of bytecode because I couldn't find up to date sources for this library.
Image

User avatar
ucim
Posts: 5564
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: Coding: Fleeting Thoughts

Postby ucim » Thu Mar 31, 2016 1:36 am UTC

If you index an array (in PHP) by ints, and you feed it a string or a float as a key, the string or float is converted to an int silently. The key "99" is essentially the same as the key 99 or the key 99.9 (but different from the key "099" or "99 luftballoons").

wat?

Jose
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Please help addams if you can. She needs all of us.

EvanED
Posts: 4324
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Thu Mar 31, 2016 2:21 am UTC

ucim wrote:wat?

Oh, that's very easy to explain:
ucim wrote:(in PHP)
[/troll]

User avatar
ucim
Posts: 5564
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: Coding: Fleeting Thoughts

Postby ucim » Thu Mar 31, 2016 2:26 am UTC

Yeah, I know PHP is kinda borked, but really... what is the thinking here? I know that PHP is designed <koff> for web stuff, and everything is passed as a string (which explains some string conversions), but I do long for strict typing.

Actually even Python doesn't do strict typing. With duck typing, you have to wait for a quack. Oops... it's local variables (that is, local to a small scope, not local to a function) that Python doesn't seem to do. PHP doesn't either.

To clarify, I'd like block scope, like C has:

a=1
b=2
{ a=3
print a
// prints 3
}
print a
// prints 1

and I was surprised Python didn't. But this has nothing to do with typing. My bad.

Jose
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Please help addams if you can. She needs all of us.

User avatar
phlip
Restorer of Worlds
Posts: 7543
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Coding: Fleeting Thoughts

Postby phlip » Thu Mar 31, 2016 3:01 am UTC

block-local vars are tricky to do in a language that doesn't use variable declarations... you can't easily define exactly which block it should be local to.

Like... everyone who's used Java will be familiar with the enjoyment of writing this:

Code: Select all

int a = somefunc();
dostuffwith(a);
except then they need to turn it into:

Code: Select all

try {
  int a = somefunc();
} catch (things) {
  throw stuff;
}
dostuffwith(a);
except now it doesn't work because it's a block-local var, so you need to mangle it further:

Code: Select all

int a = 0;
try {
  a = somefunc();
} catch (things) {
  throw stuff;
}
dostuffwith(a);

In Python, there isn't a variable declaration you can lift out of the block... so you can write:

Code: Select all

try:
  a = somefunc()
except things:
  raise stuff
else:
  dostuffwith(a)
and there isn't any obvious way to declare whether or not you want "a" to be local to the try block.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
3fj
Posts: 1715
Joined: Wed Jun 11, 2008 1:13 pm UTC
Location: Land of Whisky and Bagpipes (LOWAB)
Contact:

Re: Coding: Fleeting Thoughts

Postby 3fj » Thu Mar 31, 2016 1:11 pm UTC

Xeio wrote:

Code: Select all

if(actionDel != null) actionDel(x);
{
    match = true;
}

This is verbatim, I have not changed indentation.

WHO NEEDS READABILITY ANYWAY?

Oh god, that makes me want to be physically sick. I want to assume the best, and that they incorrectly think the random bit of block scope is conditional. The whole thing looks like someone learned about delegates that week and got excited.

Xeio wrote:Now it's essentially instant. So there's a thing. :shock:

EDIT:

Actually, this is apparently only one of two issues causing extreme slowness during the scenario I'm testing (the other is... apparently... intermittent).

It's only Monday too, fuck this week.

Oh! Are we taking bets? I want to bet messed up LINQ Where query with a side of weird Connections not being disposed of properly.

My main bugbear with my current company's code base is that they all "kind of" know how LINQ works, but only a handful really get it. We're still in the MVP/only a few customer stages, and so we're missing the data load that would cause all these statements to run at a crawl. It's usually a lack of understanding of the IQueryable/IEnumerable boundary with LINQ to SQL/LDAP, which is leading to a load of data being requested where it just isn't required.

EDIT:

Code: Select all

&utf8=✓


Just noticed this in github. There's something beautifully succinct about that.
Everything's dead until it's alive. Man will exist, and then he will die. Just take the ride!

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5086
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Thu Mar 31, 2016 3:50 pm UTC

3fj wrote:Oh! Are we taking bets? I want to bet messed up LINQ Where query with a side of weird Connections not being disposed of properly.
Sadly nothing so simple. The LINQ was seemingly just some horrible hatchetjob for a dev tracing tool (so luckily this code almost never runs).

The other issue I didn't even do much research into (uh... "It only happens on my machine" is a valid excuse right?), but had something to do with data duplicating itself. Like a table going from 5 rows to 2000+.

I found out Tuesday I'm not even working for this customer anymore (effective Monday) so my motivation to find out how a dozen or so code hooks are interacting to cause the behavior I only saw while debugging is lessened. Mostly just trying to resolve a few issues I actually have time for.

User avatar
phlip
Restorer of Worlds
Posts: 7543
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Coding: Fleeting Thoughts

Postby phlip » Mon Apr 04, 2016 3:51 am UTC

Had a fun one today... Daylight Savings just ended here, so yesterday had 25 hours, which confused a piece of code that added timedelta(days=1) to a datetime and assumed it would be the next day. It wasn't. This then flowed through to another piece of code which got confused and tried to schedule something in the past. Which made the scheduler try to sleep for negative 14 seconds. So now that thread is sleeping for over 130 years.

Yet more evidence that Daylight Savings Time is horrible and needs to die.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
ucim
Posts: 5564
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: Coding: Fleeting Thoughts

Postby ucim » Mon Apr 04, 2016 4:18 am UTC

phlip wrote:Yet more evidence that Daylight Savings Time is horrible and needs to die.
Sounds like using "mutable time" as anything other than a display thing is what has to die. Software should keep time in some immutable manner (like GMT or its cousins), and convert for display. Input should be converted to that same immutable time immediately, just like passwords should be hashed immediately.

Jose
Yes, I overloaded "immutable". So sue me. :)
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Please help addams if you can. She needs all of us.

Breakfast
Posts: 117
Joined: Tue Jun 16, 2009 7:34 pm UTC
Location: Coming to a table near you

Re: Coding: Fleeting Thoughts

Postby Breakfast » Mon Apr 04, 2016 12:20 pm UTC

3fj wrote:...

Oh! Are we taking bets? I want to bet messed up LINQ Where query with a side of weird Connections not being disposed of properly.

My main bugbear with my current company's code base is that they all "kind of" know how LINQ works, but only a handful really get it. We're still in the MVP/only a few customer stages, and so we're missing the data load that would cause all these statements to run at a crawl. It's usually a lack of understanding of the IQueryable/IEnumerable boundary with LINQ to SQL/LDAP, which is leading to a load of data being requested where it just isn't required.

...


Last week someone actually suggested to me, no lie, "Try pulling all 130,000 of your records into memory before doing your LINQ filtering. That's how we improved performance."

Seriously...? Do these people even know how LINQ to SQL or Entities works? I'm guessing not. I completely ignored them, added on index to one table, and the performance went from abysmal to instant. At this point I'm really not surprised anymore that have no grasp on what LINQ is or what it's doing.

User avatar
3fj
Posts: 1715
Joined: Wed Jun 11, 2008 1:13 pm UTC
Location: Land of Whisky and Bagpipes (LOWAB)
Contact:

Re: Coding: Fleeting Thoughts

Postby 3fj » Mon Apr 04, 2016 12:53 pm UTC

Breakfast wrote:
3fj wrote:...

Oh! Are we taking bets? I want to bet messed up LINQ Where query with a side of weird Connections not being disposed of properly.

My main bugbear with my current company's code base is that they all "kind of" know how LINQ works, but only a handful really get it. We're still in the MVP/only a few customer stages, and so we're missing the data load that would cause all these statements to run at a crawl. It's usually a lack of understanding of the IQueryable/IEnumerable boundary with LINQ to SQL/LDAP, which is leading to a load of data being requested where it just isn't required.

...


Last week someone actually suggested to me, no lie, "Try pulling all 130,000 of your records into memory before doing your LINQ filtering. That's how we improved performance."

Seriously...? Do these people even know how LINQ to SQL or Entities works? I'm guessing not. I completely ignored them, added on index to one table, and the performance went from abysmal to instant. At this point I'm really not surprised anymore that have no grasp on what LINQ is or what it's doing.


Here, and I suspect this is where the problem lies more generally too, the devs are hired on C#/ASP.NET skills first, everything else is a bonus (beyond light testing of query generation, etc.), and exacerbated by the fact we're still using code-first migrations. Essentially, they're not thinking about the way databases work when writing the query or adding columns because they're Not Database Guys™. That's not to say they're not capable of it (in fact all the guys in my team are pretty handy with their knowledge when it comes down to it!) it's just they just don't think about it.
I'm fairly new here, but it's something I'm trying to rally against.
Everything's dead until it's alive. Man will exist, and then he will die. Just take the ride!

User avatar
chridd
Has a vermicelli title
Posts: 761
Joined: Tue Aug 19, 2008 10:07 am UTC
Location: ...Earth, I guess?
Contact:

Re: Coding: Fleeting Thoughts

Postby chridd » Mon Apr 04, 2016 6:04 pm UTC

ucim wrote:
phlip wrote:Yet more evidence that Daylight Savings Time is horrible and needs to die.
Sounds like using "mutable time" as anything other than a display thing is what has to die. Software should keep time in some immutable manner (like GMT or its cousins), and convert for display. Input should be converted to that same immutable time immediately, just like passwords should be hashed immediately.

Jose
Yes, I overloaded "immutable". So sue me. :)
So for people writing programs to keep track of schedules, how would you recommend they represent an appointment/meeting/class/etc. that happens every Monday at 2 PM (considering that such things tend to stay at 2 PM local time, and if it stayed at the same time UTC when daylight savings time changed, that would probably be a bug)? What about all-day events (which are generally all of the local day, not midnight UTC to midnight UTC)?

If someone wanted to separate events into different days (in a way that makes sense to the user—i.e., not splitting in the middle of the day just because that happens to be midnight UTC) how would you recommend they do that?

If you were using an alarm clock app, would you really want it to default to waking you up in the middle of the night or in the middle of the afternoon while traveling?
~ chri d. d. /tʃɹɪ.di.di/ (Phonotactics, schmphonotactics) · they (for now, at least) · Forum game scores
mittfh wrote:I wish this post was very quotable...
flicky1991 wrote:In both cases the quote is "I'm being quoted too much!"

User avatar
ucim
Posts: 5564
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: Coding: Fleeting Thoughts

Postby ucim » Mon Apr 04, 2016 6:36 pm UTC

chridd wrote:how would you recommend they represent an appointment/meeting/class/etc. that happens every Monday at 2 PM (considering that such things tend to stay at 2 PM local time...
As a SMOP, of course. :)

You make good points; I think it depends on what needs to be done with these times.

How about: If you need to simply display them, then you could store them locally as some kind of heretical "timey-wimey" thing, and display them natively. If you need to calculate with them, then convert to UTC (or some immutable time), do the calculation, and convert back. This should sidestep the 25 hour day problems.

"all day" events would have no time. You might have different kinds of "all day", so I'd have a table of what "all day" means if I needed to convert "all day" to a specific time frame. Again, it depends on what I had to do with the appointment. If (for example) I had to use it to schedule a conference room, "all day" would have to have a specific definition (e.g. 9-5 local time) or it would be kind of useless for this purpose. But for all calculations, convert to an immutable time, and then convert back.

I'm not sure what "separating events into different days" means.

I suppose all of this pushes the smarts of time zones into the conversion function rather than the calculation function, but it'd be in fewer places (unless you succumb to the temptation of taking a shortcut and adding x hours to 9am because "how long can a conference go?"

I know - we should just create a new standard for timekeeping. :)

Jose
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Please help addams if you can. She needs all of us.

User avatar
chridd
Has a vermicelli title
Posts: 761
Joined: Tue Aug 19, 2008 10:07 am UTC
Location: ...Earth, I guess?
Contact:

Re: Coding: Fleeting Thoughts

Postby chridd » Tue Apr 05, 2016 2:29 am UTC

ucim wrote:How about: If you need to simply display them, then you could store them locally as some kind of heretical "timey-wimey" thing, and display them natively. If you need to calculate with them, then convert to UTC (or some immutable time), do the calculation, and convert back. This should sidestep the 25 hour day problems.
My "2PM every Monday" example does involve calculation, though. It involves adding a week. Or, more precisely, adding 168 hours most of the time, but occasionally adding 169 or 167 hours. Except that if you do all the calculations in local time, adding a week just works, because most events like that are based on local time.
(Of course, this fails for things like international conference calls...)

I'm not sure what "separating events into different days" means.
I'm thinking like, if you had, say, a log file, or maybe a list of files with modification times, or a list of browser history entries, or something like that, and you wanted to show it like:
Sunday:
   x:00 this happened
   y:00 this other thing happened
Monday:
   z:00 etc.
Like, when I go to my browser history, and it gives me a list of sites that I visited today, or yesterday, or in January. The cutoffs for those categories should depend on local time, not GMT/UTC. (Or a similar thing would be, searching by date.)
(This should probably also depend on cultural ideas of when a "day" starts.)
~ chri d. d. /tʃɹɪ.di.di/ (Phonotactics, schmphonotactics) · they (for now, at least) · Forum game scores
mittfh wrote:I wish this post was very quotable...
flicky1991 wrote:In both cases the quote is "I'm being quoted too much!"

User avatar
ucim
Posts: 5564
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: Coding: Fleeting Thoughts

Postby ucim » Tue Apr 05, 2016 3:05 am UTC

Well, Monday is always seven days to next Monday. So long as that remains true, you can just add seven days. This would mean starting with two parts of a "temporal location": the day, and the time, and treating them separately. When crossing a daylight saving boundary, the day doesn't care, and the time remains fixed. (Ok, I agree - this calculation should be done locally.) But I'm not sure this is really a "calculation" in the same sense as, say, finding out when a three hour appointment ends. And for a thing that lasts "exactly one week", that has to be defined across a DST boundary anyway. What's a "week"?

To me, this issue is more that day and time-of-day are two separate things that are jammed together when they maybe shouldn't be.

chridd wrote:I'm thinking like, if you had, say, a log file, or maybe a list of files with modification times, or a list of browser history entries, or something like that, and you wanted to show it like:
Sunday:
x:00 this happened
y:00 this other thing happened
Monday:
z:00 etc.
Oh, ok. You need to know when Sunday starts, of course, but the conversion software does know this. So... convert Sunday 00:00 local to whatever it is GMT, and use that to split the list.

The problem I run into is... my server is in Dallas, my users are based in Los Angeles, some of them access the site from Boston, what time do I use?

DST isn't the (only) problem. I think the main thing is that date and time should not be unified many of the times that they are.

We simply have to convince the world to abandon the idea of local time, everyone use some Immutable time, and simply get used to working (say) 15-23 (or maybe 21-29 (or 21-5-carry-the-one)), and having lunch at whatever Immutable time local noon-ish turns out to be.

Make sense?

(I didn't think so!)

Jose
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Please help addams if you can. She needs all of us.

User avatar
3fj
Posts: 1715
Joined: Wed Jun 11, 2008 1:13 pm UTC
Location: Land of Whisky and Bagpipes (LOWAB)
Contact:

Re: Coding: Fleeting Thoughts

Postby 3fj » Tue Apr 05, 2016 9:19 am UTC

ucim wrote:To me, this issue is more that day and time-of-day are two separate things that are jammed together when they maybe shouldn't be.
...
We simply have to convince the world to abandon the idea of local time, everyone use some Immutable time, and simply get used to working (say) 15-23 (or maybe 21-29 (or 21-5-carry-the-one)), and having lunch at whatever Immutable time local noon-ish turns out to be.


If your model no longer conforms to real-world usage, it's probably not the right model for the job any more. You can refer to time as radians the sun is from the ground at a particular location but it doesn't matter if people don't actually use that metric, and cramming it in when you don't have to is a relatively pointless endeavour.

That said, I think you're right in some regard. Our usage of the universal time model isn't as wide as it could be. Logging for a server in a geographic place other than yours is the perfect example. Why do I care what time it is in San Francisco that the error happened? I just need it to give me a sequence of events with metadata of how long the waits were between. This is why things like the ELK stack track it as UTC, cause it still gives you the option of conversion in the much rarer cases when you need it.
Everything's dead until it's alive. Man will exist, and then he will die. Just take the ride!

EvanED
Posts: 4324
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Tue Apr 05, 2016 3:30 pm UTC

Code: Select all

$ cat tags.cpp
struct S {};
int foo(S s);

struct S s; // including the tag is OK

int i1 = foo(S()); // calling the default constructor is OK
int i2 = foo(struct S()); // Calling the default constructor with the tag: Not OK?!

$ g++ -fsyntax-only -Wall -Wextra tags.cpp -std=c++1y                                               
huh.cpp:7:14: error: expected primary-expression before ‘struct’
 int i2 = foo(struct S()); // Calling the default constructor with the tag: Not OK?!
              ^


C++ continues to impress me with how consistent its rules are. Truly the pinnacle of language design.

User avatar
You, sir, name?
Posts: 6974
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Tue Apr 05, 2016 3:43 pm UTC

I think it's a C compatibility thing. In C, this syntax is mandatory

Code: Select all

struct S {};

struct S s; // including the tag is MANDATORY


This is invalid

Code: Select all

struct S {};

S s;

// although you can do 'struct S {} s;' if you'd like to declare both the type and the variable   ,
// or 'typedef struct {} S;' is quite popular.



C++ allows both, although the C style declaration is really only used in forward declarations as far as I know.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

EvanED
Posts: 4324
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Tue Apr 05, 2016 5:49 pm UTC

You, sir, name? wrote:C++ allows both, although the C style declaration is really only used in forward declarations as far as I know.

Sure, that's why struct S s; works. But struct S() to create a temporary doesn't, and that's really my complaint.

It's not really a practical matter, but in the name of consistency I think it really ought to work, even though that's not C syntax and it doesn't need to.

User avatar
You, sir, name?
Posts: 6974
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Tue Apr 05, 2016 6:00 pm UTC

I can see your complaint, but that's just C++. It's pretty well established that the useful subset of C++ is strictly smaller than the language itself (hence initiatives like the core guidelines).

At any rate, the language seems to be evolving away from the syntax that bothers you with the introduction of features like uniform initialization.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 6 guests