Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 436 437 [438] 439 440 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 909971 times)

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6555 on: November 08, 2014, 03:38:43 pm »

Its a good idea because it immediately communicates to you how deep each part of the code is, and because if you give the end brackets their own lines that's one line spent versus the four spaces per line of a python indent, which only wastes space if the line of code would go off the side of the screen.
Logged
"T-take this non-euclidean geometry, h-humanity-baka. I m-made it, but not because I l-li-l-like you or anything! I just felt s-sorry for you, b-baka."
You misspelled seance.  Are possessing Draignean?  Are you actually a ghost in the shell? You have to tell us if you are, that's the rule

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6556 on: November 08, 2014, 04:18:02 pm »

Screen space is less of an issue for me than not being able to jump between matching braces. Also if you use braces, you can run autoformatters over your code that automatically indent everything properly for you (as opposed to Python where the formatter needs to assume that you meant to have that number of indents there). Also multiline lambdas are awesome and fuck Python for not having those.
Logged

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6557 on: November 08, 2014, 04:23:47 pm »

Also multiline lambdas are awesome and fuck Python for not having those.

Also multiline lambdas are awesome and fuck Python for not having those.

Also multiline lambdas are awesome and fuck Python for not having those.

Quoted 3 time for truth.  :D
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6558 on: November 08, 2014, 06:00:42 pm »

Does anyone know how to make text wrap from line to line inside an SVG element? I found the reference for textArea, but that's not being implemented in firefox.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6559 on: November 08, 2014, 06:54:37 pm »

Does anyone know how to make text wrap from line to line inside an SVG element? I found the reference for textArea, but that's not being implemented in firefox.

Gah, if I was at work I could help.  I think it was something "flow". 


Edit:  Ah here it is:  http://www.w3.org/TR/2004/WD-SVG12-20041027/flow.html

Code: [Select]
<flowRoot font-size="16">
    <flowRegion>
      <path d="M100,50L50,300L250,300L300,50z"/>
    </flowRegion>
      <flowPara>Tomorrow, and tomorrow, and tomorrow; creeps in this
       petty pace from day to day, until the last syllable of recorded time.
       And all our yesterdays have lighted fools the way to dusty death.
     </flowPara>
  </flow>

You can use a rect instead of a path, that is what I usually do.
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6560 on: November 08, 2014, 07:10:40 pm »

Also multiline lambdas are awesome and fuck Python for not having those.

Quoted 3 time for truth.  :D

And again.  I was pretty disappointed to learn that Python didn't have support for it.

Inline function definitions like that are one of my favorite features of JavaScript (alongside object literals), and I miss them sorely whenever I use a scripting language that doesn't support them.  PHP relatively recently added the ability to define functions this way I think, but still lacks object literals.  (object)array() syntax works but is annoying.

Python's dictionaries are almost as convenient as object literals, but having to use the [] operator to access their components is distracting compared to just using them as objects.  I suppose there are benefits to making it clear that you're working with a dictionary rather than another type of object though.
Logged
Through pain, I find wisdom.

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6561 on: November 08, 2014, 07:11:11 pm »

Ah, thank you. I'll see what I can do with that.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #6562 on: November 09, 2014, 01:09:03 am »

Oh, you meant indentation. Right.

I don't like curly-bracket languages because curly brackets look weird. When it comes to programming, I'm very superficial.
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6563 on: November 09, 2014, 01:22:19 am »

I had to look up lambdas.

I'm still not sure what they are.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6564 on: November 09, 2014, 01:45:16 am »

Say there's a function that takes a function as an argument. Let's use the example of "timer", a function that runs another function after a second.

In lua, you can do this:

Code: [Select]
timer(function() print('Hello')
    print('World!)
    end)

In python, it must go like this:

Code: [Select]
timer(lambda: print('Hello') print('World!'))
Or something like that. Anyway, I've seen code that used \ to escape line breaks, so...

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6565 on: November 09, 2014, 02:14:36 am »

Yep, whereas in JavaScript (and I think modern versions of PHP), you can do something like this:

Code: [Select]
setTimeout(function() {
    // Do stuff
    // And more stuff
}, 1000);

Which is equivalent to doing this:

Code: [Select]
function foo() {
    // Do stuff
    // And more stuff
}
setTimeout(foo, 1000);

Being able to define multiline functions inline as arguments is very handy, especially when you're working with things that require custom callbacks for asynchronous events.
Logged
Through pain, I find wisdom.

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6566 on: November 09, 2014, 04:08:20 am »

I never got around to thanking Sergius and Arx for helping me out with SQL, thanks a lot for everything you guys.
Logged

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #6567 on: November 09, 2014, 04:24:37 am »

Code: [Select]
print ("Ohai!",
       len ("""I am a Python
multiline lambda thingy""") * 3,
       "even though I don't know what any of it is",
       [print ("you guys seem pretty worked up about it",
               i) for i in range (11)])
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6568 on: November 09, 2014, 10:56:45 am »

Code: [Select]
print ("Ohai!",
       len ("""I am a Python
multiline lambda thingy""") * 3,
       "even though I don't know what any of it is",
       [print ("you guys seem pretty worked up about it",
               i) for i in range (11)])

Syntax error.

Also, not a lambda.
Logged

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6569 on: November 09, 2014, 10:58:01 am »

Thanks for the effort, guys.

Still makes no sense at all to me.
Logged
Pages: 1 ... 436 437 [438] 439 440 ... 796