## Coding: Fleeting Thoughts

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

Moderators: phlip, Moderators General, Prelates

TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

### Re: Coding: Fleeting Thoughts

e^iπ+1=0 wrote:
So if you do "x.append(z)", you end up with "[[]]". If you do "x.append(y)" instead though, you end up with "[[...]]", because x and y point to the same object.

This is the bit I don't. I realize that my a=a+1 example used integers, but that was (I thought) beside the point I was trying to make. It takes the value of a at the time, adds 1 to it, and stores that back in a. a.append(a) should similarly take the value of a at the time and add it to the list a. It shouldn't reevaluate that statement to take the new value of a over and over again.

The value of the variable is a pointer. That would not change. What changes is what it points to.

http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

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

### Re: Coding: Fleeting Thoughts

In general, if you do "a = something" then you're replacing the object that's stored in a, but if you do "a.foo = something" or "a.bar()" or "a[0] = something" or the like, then you're you're modifying the object a is referring to.

So a more accurate analogy to "a = a + 1" would be "a.add(1)", which, if numbers were mutable, would change the actual number object a was referring to... and if that was aliased to other variables, then those would change too. And if you did "a.add(a)" then it could potentially get rather confused, as it is changing the number at the same time as reading it (though in this particular case it would probably still be OK, and just double the number as expected).

As an aside, Python is a bit of an anomaly here in that "a += 1" could actually go either way... it could be like "a = a + 1" or like "a.add(1)" depending on how that particular class has defined "+=". In most languages, this is more well-defined, independent of the overloading in place for a particular class.

Code: Select all

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

Steax
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

### Re: Coding: Fleeting Thoughts

FT: For a quick and dirty CAPTCHA, I wonder if a rough one-IP-can-only-do-action-5-times-in-an-hour limit could work? Sure people have proxies and whatnot, but it would limit the overall spamability, no?
In Minecraft, I use the username Rirez.

Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

### Re: Coding: Fleeting Thoughts

Steax wrote:FT: For a quick and dirty CAPTCHA, I wonder if a rough one-IP-can-only-do-action-5-times-in-an-hour limit could work? Sure people have proxies and whatnot, but it would limit the overall spamability, no?

False positives would be really annoying for actual humans, and even 5 spams/hour is too much spam. This is a bad idea.

Unrelated FT: Haskell has a really good FFI. Both the language support and the tooling is awesome. Having written JNI bindings before, FFI code that looks like this makes me smile:

Code: Select all

`{#pointer Context foreign newtype #}foreign import ccall unsafe "&sfContext_Destroy"  contextDestroy :: FinalizerPtr ContextmkContext :: Ptr Context -> IO ContextmkContext ctx = do  ctx' <- newForeignPtr contextDestroy ctx  return (Context ctx'){#fun unsafe Context_Create as ^ {} -> `Context' mkContext* #}{#fun unsafe Context_SetActive as ^ {withContext* `Context', `Bool'} -> `()' #}`

All garbage collected, all in a few lines of code.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

Steax
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

### Re: Coding: Fleeting Thoughts

I'm looking for a CAPTCHA that doesn't involve reading text (not all of my target audience will be capable of it). Any ideas/thoughts?
In Minecraft, I use the username Rirez.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Contact:

### Re: Coding: Fleeting Thoughts

I'm thinking something with images. Maybe see this for inspiration.

But it could even be simpler... have several images of solid colors, and say "select the blue one".

Spammers would probably have to specifically target your site if you make up something; it'd be interesting to see how long that'd take.

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

### Re: Coding: Fleeting Thoughts

Making CAPTCHA that will stop general-purpose spambots: actually pretty simple, just do something sufficiently different to other solutions.

Making CAPTCHA that will stop a spambot that is specifically targeting you: very complicated, and more of an arms-race than an actual target to meet.

If you're not a large popular site, and/or distributing your CAPTCHA to be run on many sites (eg ReCAPTCHA) then the first thing is probably enough.

Code: Select all

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

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Contact:

### Re: Coding: Fleeting Thoughts

Just as a point of comparison: Jeff Atwood used to have the following captcha for codinghorror.com: "enter the word orange in the box below." ("Orange" was an image that was in a fancy, gotchicish font, but no more.) The word never changed -- it was always orange.

And his site... probably more popular than yours will be for a while.

(A few months ago he did revamp his site when something somewhat catastrophic happened to the old one and he needed to do a little rebuilding. So the "orange" captcha is no more.)

Steax
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

### Re: Coding: Fleeting Thoughts

I'm thinking of incrementing the difficulty level.

- Always include a honeypot (field hidden with CSS (using clipping)) and ensure that nothing gets filled in there. No difficulty for users.
- Always check how long it takes between page request and submit. Any less than 10 seconds (minimum limit for even someone copy-pasting/autocompletes with, say, 5 text fields?) will require a reCAPTCHA.
- After 3 submits from 1 IP in an hour, additional ones require reCAPTCHA.

I am well aware that I don't need to really block spammers - this is a contact form, so there's no point spamming links here. I do think I will be more targeted as an individual site due to the nature of my website. I don't think I can block those, so I'll just let them come in and ignore them.
In Minecraft, I use the username Rirez.

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

### Re: Coding: Fleeting Thoughts

EvanED wrote:Just as a point of comparison: Jeff Atwood used to have the following captcha for codinghorror.com: "enter the word orange in the box below." ("Orange" was an image that was in a fancy, gotchicish font, but no more.) The word never changed -- it was always orange.

And his site... probably more popular than yours will be for a while.

(A few months ago he did revamp his site when something somewhat catastrophic happened to the old one and he needed to do a little rebuilding. So the "orange" captcha is no more.)

A local newspaper has a static one as well. It reads "What is [1+3]?" where [] denotes a jpeg with obvious artifacts.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

### Re: Coding: Fleeting Thoughts

Berengal wrote:Unrelated FT: Haskell has a really good FFI. Both the language support and the tooling is awesome.

On a continued tangent, the FFI can be treacherous at times. It isn't here-be-dragons exactly, but more like here-be-not-dragons-actually-but-a-drakeling-or-two-shouldn't-be-too-surprising.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

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

### Re: Coding: Fleeting Thoughts

I remember when I first tinkered with the FFI in Haskell... I spent ages bumping against bugs and assuming I wasn't setting everything up right... bashed my head against the wall for a couple of hours, changing and rearranging all the declarations and calls and such, before eventually realising that MSDN lies, and OpenClipboard and GetClipboardData don't actually call SetLastError when they fail. And even a C program will say "Couldn't open clipboard: error 0 - Success" or the like.

Code: Select all

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

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

### Re: Coding: Fleeting Thoughts

Berengal wrote:Just thought I'd share what I'm working on with you. Properly anonymized by removing everything except code structure.

"Woah, it looks like they wrote the entire program in one huge function!" you say. I wish they did. There's more of these.
I've been thinking about this lately, I almost wonder what you would say if you say one of the files I work with on a weekly basis at work. Granted, we're working on removing it entirely... eventually...

Also, I just found an 80,000 line file, though it would probably be closer to 8,000 if it used implicit properties. It's related to the above file. Don't worry the code file is only 11,000 lines though, and the longest function is only 300ish lines (that I saw).

This should really have been done in the tool we have explicitly for XML trees...

llamanaru
Posts: 241
Joined: Sat May 01, 2010 2:40 am UTC

### Re: Coding: Fleeting Thoughts

That sounds rather painful Xeio... I thought the ~500 line files I inherited were terrible...

All the Haskell talk on this board and Rippy's questions in the "It doesn't work thread" have gotten me thinking that I should expand my horizons beyond the imperative. Any suggestions for which functional language to start with?

Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

### Re: Coding: Fleeting Thoughts

Clojure's also good.
I've seen good things in Erlang, but I haven't used it much myself.

The good thing about Haskell is that forces you to let go of your tainted imperative approach right away; there's no secret escape back to the familiar. The bad thing about this is that you'll feel like a fish on dry land at first; even less competent than you were before you learned how to program at all. Once you get past the initial hurdle, which shouldn't take long if you stick to it, all the good things you know will become useful again. Indeed, many old ideas will become that much clearer and more applicable since they'll now be clearly separated from any paradigms. At least this was my experience.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

b.i.o
Green is the loneliest number
Posts: 2519
Joined: Fri Jul 27, 2007 4:38 pm UTC
Location: Hong Kong

### Re: Coding: Fleeting Thoughts

One pretty easy way to get started is with Racket (http://www.racket-lang.org/; formerly PLT Scheme). It comes with a mini-IDE that makes getting started very very easy. (And if you're using a Lisp/Scheme dialect then you can get started with The Little Schemer, which is one of my favorite programming books.)

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

### Re: Coding: Fleeting Thoughts

llamanaru wrote:That sounds rather painful Xeio... I thought the ~500 line files I inherited were terrible...
Yup, for the most part the code base isn't bad, but this is one of those things that apparently was needed done "quick" rather than "correct". And of course, since then it's become an integral part of the application that nearly every customer uses and needs regular updates...

One of the architects went into a rant about it actually during one of the meetings I was in because he was around protesting the original decision.

Steax
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

### Re: Coding: Fleeting Thoughts

Forums and commenting systems could use twitter style hashtags and @ thingies.

(... other questions and rambling ...)

SomeOneElse wrote:(... other responses and stuff ...)

#javascript I don't think it's natively possible.

(... other posts ...)

It can also use meta information like seeing which post YetAnotherUser hit "Reply" on, and automatically create a link on the @SomeThreadStarter text to the original post. When not available, they can link to the last post by that person (or show it as a tooltip/expand it), and do other stuff like highlight that person's post (or maybe even show a "conversation" button). Hashtags, when clicked, can hide posts which don't include the hashtag (with or without the #, so posts without the hashtag being explicitly defined also get included).

It's not intrusive, and it can be used alongside good old BBcode. But it would help clarify how conversations flow on web forums without wasting space with giant quotes.

Just a thought. Probably could use some refinement.

______

Also, more of a design thing, but whatever:

Why do forums' most important UI elements become the smallest ones? The most common functions I use on the xkcd forums are:
- Jumping to last unread post in thread. How: Hit the tiny 11x9 pixel icon beside thread name
- Moving to next page in thread. How: Hit 26x15 pixel "Next" text link on bottom lower right of thread near pagination
- Finding posts in response to mine. How: Scan all threads where I've replied in, and see if anyone replies (why not show clearly when someone mentions my screen name or quotes a post of mine?)

Overall a lot of things can be improved just by making bigger buttons. Take the breadcrumbs to forum sections on the top edge. They're inline text links. Why not floated block elements so we can use the wide padding for extra clickable space?

(Nothing against this forum in particular, of course, I love it here and those faults are part of the template I'm using. It's just a sort of trend that probably needs to change. Hitting those buttons on my iphone is depressing.)
In Minecraft, I use the username Rirez.

b.i.o
Green is the loneliest number
Posts: 2519
Joined: Fri Jul 27, 2007 4:38 pm UTC
Location: Hong Kong

### Re: Coding: Fleeting Thoughts

I've long been of the opinion that forum software sucks, and forum UIs are awful.

However, the issue is that there's very little motivation to write good, new forum software, because forum software is a niche that's basically impossible to break into.

mister_m
Posts: 34
Joined: Fri Feb 04, 2011 2:51 am UTC

### Re: Coding: Fleeting Thoughts

I want to write a simple graph library based that is similar to JGraphT in how it is used, but way smaller in scope. I'd like to limit it to wighted or unweighted, and directed/undirected simple/multigraph/graphs initially, and then possibly expand based on how much time I have.

Currently I'm thinking about what kinds of classes I would need, and interfaces. I want to try to do some good design on this one so I can actually use the library in a project - which would be cool. Right now I am thinking I could have a graph interface with whatever methods I want, and have various different kinds of graphs, I guess implement that. That is about as far as I have gotten. I'd like to eventually use the library to create finite state machines inside of my programs, so I would like for each node of the graph to be some kind of Object (I don't care which kind, at this point, but they have to hold some kind of data).

Trouble is, I've never done anything quite like this before, and I'd like to get at least a library working for simplegraphs. I think that would be a fun learning experience. Does anyone have any tips? I was looking at the javadocs for the JGraphT library(here: http://www.jgrapht.org/javadoc/) and I am seriously very concerned about the complexity of them. For example, they have a graph interface, and they have an AbstractBaseGraph that implements it, and then various types of graphs that subclass the AbstractBaseGraph. Am I correct in thinking that is so the interface only has to be implemented in one place?

I know really othing about working with generics, or building anything like this. Should I start with something else do you think?

Steax
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

### Re: Coding: Fleeting Thoughts

FT: Why don't forums and comment thread implement auto-refreshing like every 5 mins? Don't even need to fully refresh anyway, just have the server pass a hash on what thread/comment IDs are already available and pass any new ones. AJAX, people. WHY MUST I KEEP HITTING REFRESH WHYYYY IT KILLS MY SANITY SDFDSGSDGSDG
In Minecraft, I use the username Rirez.

diabolo
Posts: 72
Joined: Fri Aug 08, 2008 4:17 pm UTC
Location: france

### Re: Coding: Fleeting Thoughts

Steax wrote:FT: Why don't forums and comment thread implement auto-refreshing like every 5 mins? Don't even need to fully refresh anyway, just have the server pass a hash on what thread/comment IDs are already available and pass any new ones. AJAX, people. WHY MUST I KEEP HITTING REFRESH WHYYYY IT KILLS MY SANITY SDFDSGSDGSDG

Last time I checked Opera had a "refresh every ..." feature and there were Firefox extensions doing the same thing.
It doesn't really solve the problem (reloading everything vs only what's changed) but you don't have to keep clicking so maybe it can help your sanity last a bit longer.

Steax
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

### Re: Coding: Fleeting Thoughts

I tried one of those in firefox, but it caused the tab (pinned as an app tab) to always indicate "new content" every time it refreshed. Gmail and Facebook and so forth will change when they get new content, and FF4 recognizes that and shows a neat little indicator light to show that it's updated, and I notice that at the corner of my screen so I just go there and see what's new, without having to open the tab at all.

This is driving me bonkers. Every time I want to go out and do something, there's always that fleeting "I wonder if anyone replied to my witty post, I should reply quickly to show appreciation" thought floating around. Dammit.
In Minecraft, I use the username Rirez.

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

### Re: Coding: Fleeting Thoughts

I'm sure a greasemonkey script could do it, if you have the patience to write such a thing. Have it "refresh" the page with AJAX, then search for this image. If it exists on the page, there are new posts, and you can do a proper refresh.

<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Cheese> I love you

Robert'); DROP TABLE *;
Posts: 730
Joined: Mon Sep 08, 2008 6:46 pm UTC
Location: in ur fieldz

### Re: Coding: Fleeting Thoughts

It will if you search for that image with the title text, "Unread post", though.
...And that is how we know the Earth to be banana-shaped.

Steax
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

### Re: Coding: Fleeting Thoughts

Hmmm, interesting. Worth a try. jQuery should make crawling the AJAX results fairly easily. I hope one day it latches on everywhere though.
In Minecraft, I use the username Rirez.

diabolo
Posts: 72
Joined: Fri Aug 08, 2008 4:17 pm UTC
Location: france

### Re: Coding: Fleeting Thoughts

headprogrammingczar wrote:I'm sure a greasemonkey script could do it, if you have the patience to write such a thing. Have it "refresh" the page with AJAX, then search for this image. If it exists on the page, there are new posts, and you can do a proper refresh.

Since you only need to know if anything changed and not exactly what's new maybe you could use the corresponding forum/subforum/thread RSS feed and look at the most recent dates. It should be lighter than fetch all the html and look for images.

TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

### Re: Coding: Fleeting Thoughts

I think this forum supports AJAX.

http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

Windowlicker
Posts: 323
Joined: Wed Dec 23, 2009 6:57 pm UTC
Location: St Andrews, Scotland

### Re: Coding: Fleeting Thoughts

Another (possibly daft) Java question.. if I create an ArrayList<Thread>, and then a thread that is stored within that arraylist expires, will it remove itself/be automatically removed? Will its value just become null? I realise creating this in the first place might be a questionable practice in the first place, but I'm in something of a rush and am just sort of throwing code down.

jaap
Posts: 2094
Joined: Fri Jul 06, 2007 7:06 am UTC
Contact:

### Re: Coding: Fleeting Thoughts

Windowlicker wrote:Another (possibly daft) Java question.. if I create an ArrayList<Thread>, and then a thread that is stored within that arraylist expires, will it remove itself/be automatically removed? Will its value just become null?

No. An instance of Thread is an ordinary object just like every other, and simply contains the bookkeeping used to keep track of the execution of a thread. To see if the thread controlled by this object has finished its execution, you can call its .getState() member function and check if the return value is Thread.State.TERMINATED.

Windowlicker
Posts: 323
Joined: Wed Dec 23, 2009 6:57 pm UTC
Location: St Andrews, Scotland

### Re: Coding: Fleeting Thoughts

jaap wrote:
Windowlicker wrote:Another (possibly daft) Java question.. if I create an ArrayList<Thread>, and then a thread that is stored within that arraylist expires, will it remove itself/be automatically removed? Will its value just become null?

No. An instance of Thread is an ordinary object just like every other, and simply contains the bookkeeping used to keep track of the execution of a thread. To see if the thread controlled by this object has finished its execution, you can call its .getState() member function and check if the return value is Thread.State.TERMINATED.

Aaaah that makes more sense, thank you. Jumping feet-first strikes again...

Steax
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

### Re: Coding: Fleeting Thoughts

FT: Sometimes CSS specificity is annoying.

Code: Select all

`<section id="stage">    <p id="stage-1">        Something here    </p>    <p id="stage-2">        Something here    </p>    <p id="stage-3">        Something here    </p></section>`

My instincts would style them as so:

1. Style each paragraph in the stage. I could use classes, but lets just select all paragraph elements. That's the 'cascading' part, no?

Code: Select all

`#stage p{    color: black;}`

2. Now I want to style the third one differently... so lets do that.

Code: Select all

`#stage-3{    color: red;}`

Of course, that won't work. The color will stay black because the first selector had higher specificity. Yes, fixing it is easy... #stage #stage-3 will work, or even just p#stage-3. But it often annoys me midway through. "Why the heck is this not changing, I specifically want that ID to... oh. wait." *opens firebug and finds the offending code*

Yeah I know the specificity stuff is important too. It just annoys me sometimes.
In Minecraft, I use the username Rirez.

TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

### Re: Coding: Fleeting Thoughts

Okay, pop quiz. Which one of these will cause a linker error?

Code: Select all

`struct Foo { static const double bar = 10; };int main (){    std::cout << Foo::bar << '\n';} `

Code: Select all

`struct Foo { static const double bar = 10; };int main (){    std::cout << -Foo::bar << '\n';} `

Code: Select all

`struct Foo { static const double bar = 10; };int main (){    std::cout << (Foo::bar * -1) << '\n';} `

Code: Select all

`struct Foo { static const int bar = 10; };int main (){    std::cout << Foo::bar << '\n';}  `

Code: Select all

`struct Foo { static const int bar = 10; };int main (){    std::cout << -Foo::bar << '\n';}  `

Code: Select all

`struct Foo { static const int bar = 10; };int main (){    std::cout << (Foo::bar * -1) << '\n';}  `

And here I was thinking I understood static linking...

http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

_Axle_
Posts: 253
Joined: Fri Sep 24, 2010 7:33 pm UTC

### Re: Coding: Fleeting Thoughts

That is interesting Chew.... I will add that to things I didn't know before.
Yakk wrote:Computer Science is to Programming as Materials Physics is to Structural Engineering.

userxp
Posts: 436
Joined: Thu Jul 09, 2009 12:40 pm UTC

### Re: Coding: Fleeting Thoughts

Why isn't a "forever:" keyword standard in all languages?
Yes, you can use "while True:" or "for (;;)" or even a GOTO, but it seems to me that a statement for infinite loops would be an useful (and easy) addition to any language.

Sc4Freak
Posts: 673
Joined: Thu Jul 12, 2007 4:50 am UTC
Location: Redmond, Washington

### Re: Coding: Fleeting Thoughts

Because in general, you want to keep syntax to a minimum. There's no point introducing a new language keyword (which might conflict with existing identifiers in people's code, by the way) when it doesn't really provide anything useful. A "forever" keyword doesn't save you any typing, doesn't do anything new, and isn't much more readable than while(true) or for(;;).

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

### Re: Coding: Fleeting Thoughts

Chewanator: This, however, does work:

Code: Select all

`struct Foo { static const double bar; };const double Foo::bar = 10;int main (){    std::cout << -Foo::bar << '\n';}`
The compiler warnings say something about only being able to define a constant static variable inside the class like that if it's an integer? I dunno. I'm guessing it's something to do with the fact that the class definition would normally go in a header, but the static variable definition would normally go in a cpp file (so there's only one of them, that everything links to).

I don't know why it only fails with the unary minus, and not the other cases, but I'm guessing the other cases only worked by chance or something.

Code: Select all

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

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

### Re: Coding: Fleeting Thoughts

phlip wrote:I don't know why it only fails with the unary minus, and not the other cases, but I'm guessing the other cases only worked by chance or something.
On my compiler (i686-apple-darwin9-g++-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5490)) all three of the cases with double fail.
~ chri d. d. /tʃɹɪ.di.di/ (Phonotactics, schmphonotactics) · she · Forum game scores
mittfh wrote:I wish this post was very quotable...

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

### Re: Coding: Fleeting Thoughts

Well, that backs up the "only by chance" guess... for gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 the plain one works, as does the *-1 one, but the unary minus one fails with an undefined reference in the linker. Though all three give a warning if you turn warnings on.

Code: Select all

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

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

### Re: Coding: Fleeting Thoughts

Also all of them work without error if I use -O1. And for some reason the version I'm using doesn't give any warnings if I just use -Wall (but it gives an error if I use -pedantic).
~ chri d. d. /tʃɹɪ.di.di/ (Phonotactics, schmphonotactics) · she · Forum game scores
mittfh wrote:I wish this post was very quotable...