Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
GameCube
Nov 21, 2006

it is friday night and i am having fun converting every one of my functions that creates an unnecessary new List to yield iterators instead. i'm very cool and popular

Adbot
ADBOT LOVES YOU

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal
more like lazy

GameCube
Nov 21, 2006

hehe

triple sulk
Sep 17, 2014



i'm checking out a bug backlog. they aren't fun lemme tell you

GameCube
Nov 21, 2006

i have crawled waaaaaaaaaaaaaay up my own rear end in a top hat
code:
public static IEnumerable<Tuple<IEnumerable<Mome>, IEnumerable<Chome>>> Lomarf(IEnumerable<IEnumerable<Mome>> momes, IEnumerable<IEnumerable<Chome>> chomes)
this is for a unit test

abraham linksys
Sep 6, 2010

:darksouls:

GameCube posted:

it is friday night and i am having fun converting every one of my functions that creates an unnecessary new List to yield iterators instead. i'm very cool and popular

i'm spending my friday night cloning unity's GameObject/Component system for a typescript games framework, it's been weird and the more time i spend on this the more time i am surprised unity's scripting system works half as well as it does

i'm pretty sure game objects-as-buckets-of-components is an improvement on, like, traditional OOP or mixins, but seems to have a lot of problems of its own

also i was looking at tutorials and trying to figure out how you'd architect a top-level "game controller" component and the answer is apparently to make a fuckin singleton so now i trust unity even less than i did before

GameCube
Nov 21, 2006

have u seen this http://gameprogrammingpatterns.com/

abraham linksys
Sep 6, 2010

:darksouls:

yea and what i'm implementing is basically http://gameprogrammingpatterns.com/component.html :)

so far i've just happened to agree with most of how unity implements this pattern but there are places where i'd consider changing things so i should probably re-read the last section of that again

GameCube
Nov 21, 2006

abraham linksys posted:

yea and what i'm implementing is basically http://gameprogrammingpatterns.com/component.html :)

so far i've just happened to agree with most of how unity implements this pattern but there are places where i'd consider changing things so i should probably re-read the last section of that again

that is just one of many game programming books i read and then never acted on. godspeed

abraham linksys
Sep 6, 2010

:darksouls:
my plan is to get this in a stable enough place that i can make a game with it at a game jam next weekend. if not, i will just consider it the weirdest way anyone has ever learned unity's scripting API, because I've learned more from this than any of the number of times I downloaded Unity and tried to actually make anything with it

brap
Aug 23, 2004

Grimey Drawer
laziness can be ok as long as you aren't producing any side effects. honestly I ToList much of the time because I figure callers may enumerate return values multiple times as well.

an ienumerable of ienumerables is definitely something I would raise an eyebrow at

with all perf questions: don't do poo poo that's obviously inefficient, but question your assumptions and run a profiler if perf matters at all in your situation

Xarn
Jun 26, 2015

YeOldeButchere posted:

welp i'm an idiot

the worst part of this is that i know i've seen stuff like that in undergrad, especially in the third algorithms and data structures course where a huge part of it was linear programming and other optimization problems, and how most of it is np but some can be approximated within a known bound. this totally feels like an assignment question and it pisses me off that i can't answer it!

Is there a reason not to throw these into an ILP solver?

stramit
Dec 9, 2004
Ask me about making games instead of gains.

fleshweasel posted:

laziness can be ok as long as you aren't producing any side effects. honestly I ToList much of the time because I figure callers may enumerate return values multiple times as well.

I tend to not do this. Users can call ToList on the returned collection of they need multiple enumeration.

abraham linksys posted:

i'm spending my friday night cloning unity's GameObject/Component system for a typescript games framework, it's been weird and the more time i spend on this the more time i am surprised unity's scripting system works half as well as it does

i'm pretty sure game objects-as-buckets-of-components is an improvement on, like, traditional OOP or mixins, but seems to have a lot of problems of its own

The hardest part is cross component messaging. If you have (logically built) component dependencies then you'll want to have dependent components do things when their dependency is changed. An example in Unity is the UISprite, when you change a field on this (say the actual sprite), you'll want to message any sibling components that this has changed. There are a few ways to do this and you generally fall back to either messaging (SendMessage in Unity / maybe checking interfaces and issuing calls if siblings implement them). The complexities arise because you don't know which fields sibling components will be interested in, so you end up either having a bunch of callback in the main component that siblings can register against of a full crazy messaging system. Basically you end up with a bunch boilerplate code that you need to maintain that may or may not ever be used because you can't be sure what the sibling components will need. This isn't so much an issue of you are just writing something for a single application (just code what you need); but when you have a real system (like the Unity UI) it's really hosed and every time you miss one callback you'll have consumers of the system complaining that a callback is missing. Then you'll also have them complain that things are slow because everything has callbacks and it takes time to check / invoke them, even if they are not used.

stramit fucked around with this message at 08:27 on Jul 23, 2016

GameCube
Nov 21, 2006

fleshweasel posted:

laziness can be ok as long as you aren't producing any side effects. honestly I ToList much of the time because I figure callers may enumerate return values multiple times as well.
yup i learned that lesson the hard way. what do you mean key not found?? oh my generator for a thing was an iterator that meant new objects were being created when i didn't want them to be. oops

quote:

an ienumerable of ienumerables is definitely something I would raise an eyebrow at

with all perf questions: don't do poo poo that's obviously inefficient, but question your assumptions and run a profiler if perf matters at all in your situation
this is all pure jackoffery, i'm using it to generate test cases for a unit test and just learn how to C# in the process. it's pretty doubtful that this is actually benefiting me in any way other than education

speaking of which, how do i profile

GameCube
Nov 21, 2006

lmfao somehow i generated almost 2000 test cases for one method. our QA manager will be very pleased with these numbers

redleader
Aug 18, 2005

Engage according to operational parameters

Strumpy posted:

I tend to not do this. Users can call ToList on the returned collection of they need multiple enumeration.

i use IEnumerable<T> as the return type but actually return List<T>. this is because most of my colleagues don't know anything about IEnumerable and multiple enumeration and iterator methods and laziness and such

i also have an annoying habit of always typing IEnumberable

HoboMan
Nov 4, 2010

Bloody posted:

I think the answer involves taking the floor and ceiling of Cy / K and using them as Ax and Bx and then calculating appropriate Ay and By given those Ax and Bx

this was my line of thinking but i didn't flesh out anything more concrete before getting drunk

the was something with modulos i worked out where you could quickly check Cx*Kor something to see if there was no valid solution (but i don't think passing guarantess a solution)

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

GameCube posted:

lmfao somehow i generated almost 2000 test cases for one method. our QA manager will be very pleased with these numbers

you should do property testing

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

GameCube posted:

i have crawled waaaaaaaaaaaaaay up my own rear end in a top hat
code:
public static IEnumerable<Tuple<IEnumerable<Mome>, IEnumerable<Chome>>> Lomarf(IEnumerable<IEnumerable<Mome>> momes, IEnumerable<IEnumerable<Chome>> chomes)
this is for a unit test

if you really need those nested generics but don't want to type them everywhere, you can sometimes "alias" them depending on how you use them

code:
public interface WorbleGorble : IEnumerable<Tuple<IEnumerable<Mome>, IEnumerable<Chome>>>
{
}

AWWNAW
Dec 30, 2008

NihilCredo posted:

if you really need those nested generics but don't want to type them everywhere, you can sometimes "alias" them depending on how you use them

code:

public interface WorbleGorble : IEnumerable<Tuple<IEnumerable<Mome>, IEnumerable<Chome>>>
{
}

or you can alias them using a using statement at the top of the file like using Dick = System.Tuple<Pussy,Taint>

AWWNAW
Dec 30, 2008

that way you don't have to define new types and yeah check out property testing to go further up your own rear end and then move to F#

Luigi Thirty
Apr 30, 2006

Emergency confection port.

neato

- rendering is synced with vsync and locked to 35fps
- objects now have a velocity vector that gets applied to their translation position every frame
- coming soon: commanding objects to rotate to face (X,Y,Z) in T frames???

i'm winner

brap
Aug 23, 2004

Grimey Drawer
if you return a list as an ienumerable people are just gonna ToList it and create a new list instance. whoops

nrook
Jun 25, 2009

Just let yourself become a worthless person!
Oh does C# not have an immutable list type built in yet? I'm surprised, I would have thought they'd have one by now.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

AWWNAW posted:

or you can alias them using a using statement at the top of the file like using Dick = System.Tuple<Pussy,Taint>

huh, thought for some reason that didn't work on generics, cool

fleshweasel posted:

if you return a list as an ienumerable people are just gonna ToList it and create a new list instance. whoops

yeah but at least they aren't gonna mess with your list that way. i think one huge reason ienumerable was returned everywhere because ireadonlylist didn't exist until .net 4.5

if you're writing a pure function, sure, you can hand over the original list no problem. but if it's a property or something you absolutely want to return an immutable interface

NihilCredo fucked around with this message at 18:42 on Jul 23, 2016

HoboMan
Nov 4, 2010

GameCube posted:

yup i learned that lesson the hard way. what do you mean key not found?? oh my generator for a thing was an iterator that meant new objects were being created when i didn't want them to be. oops

wait, what? please elaborate so i don't have to learn the hard way as well

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

nrook posted:

Oh does C# not have an immutable list type built in yet? I'm surprised, I would have thought they'd have one by now.

nah, system.collections.immutable has existed for four years but people are slow to adopt it when they're already used to exposing ienumerable which 90% of the time does the job just fine

nrook
Jun 25, 2009

Just let yourself become a worthless person!

NihilCredo posted:

nah, system.collections.immutable has existed for four years but people are slow to adopt it when they're already used to exposing ienumerable which 90% of the time does the job just fine

oh ok that's good.

an advantage of immutable collections is that in any decent implementation "copying" a list is O(1). so if you make an immutable list and return it as an IList or IEnumerable and then the caller decides to make an immutable list from your return value, you aren't doing a bunch of pointless calculations

Gul Banana
Nov 28, 2003

GameCube posted:

i have crawled waaaaaaaaaaaaaay up my own rear end in a top hat
code:
public static IEnumerable<Tuple<IEnumerable<Mome>, IEnumerable<Chome>>> Lomarf(IEnumerable<IEnumerable<Mome>> momes, IEnumerable<IEnumerable<Chome>> chomes)
this is for a unit test

we really need some syntax sugar for what shoulda been core builtins there. 'public static [([Mome], [Chome])] Lomarf([[Mome]] momes, [[Chome]] chomes)' would look fine

LordSaturn
Aug 12, 2007

sadly unfunny

Gul Banana posted:

we really need some syntax sugar for what shoulda been core builtins there. 'public static [([Mome], [Chome])] Lomarf([[Mome]] momes, [[Chome]] chomes)' would look fine

we need to stop expanding C++, it's 2016 and you can just use a good language if you loving want to

brap
Aug 23, 2004

Grimey Drawer
C# should have type aliases

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
it's a lot more readable when you flatten your monads and give your return value a proper name instead of using a tuple

code:
public static IEnumerable<LomarfResult> Lomarf(IEnumerable<Mome> momes, IEnumerable<Chome> chomes)

Chamook
Nov 17, 2006

wheeeeeeeeeeeeee
Why would you ever want more than:
code:
let lomarf momes chomes =
    ...

30 TO 50 FERAL HOG
Mar 2, 2005



we need a yospos programming language thats nothing except fizz buzz lomarf and chome

we can do a lot with four keywords right?

Su-Su-Sudoko
Oct 25, 2007

what stands in the way becomes the way

BiohazrD posted:

we need a yospos programming language thats nothing except fizz buzz lomarf and chome

we can do a lot with four keywords right?

something like this https://esolangs.org/wiki/ook!

Sapozhnik
Jan 2, 2005

Nap Ghost

LordSaturn posted:

we need to stop expanding C++, it's 2016 and you can just use a good language if you loving want to

People use C and then they're like "ugh I hate doing vtables by hand, maybe I'll just use a little bit of C++ but program it as if it were C"

"I'll just do a little meth, I'm a strong-willed person with lots of self control, it can't be that much of a slippery slope, can it?"

hobbesmaster
Jan 28, 2008

LordSaturn posted:

we need to stop expanding C++, it's 2016 and you can just add whatever feature you want using boost spirit/phoenix

Asymmetrikon
Oct 30, 2009

I believe you're a big dork!

Chamook posted:

Why would you ever want more than:
code:
let lomarf momes chomes =
    ...

because top level type inference is awful. leave inference where it belongs (lets inside a function) and be explicit with your interface

HoboMan
Nov 4, 2010

Mr Dog posted:

People use C and then they're like "ugh I hate doing vtables by hand, maybe I'll just use a little bit of C++ but program it as if it were C"

"I'll just do a little meth, I'm a strong-willed person with lots of self control, it can't be that much of a slippery slope, can it?"

Worked for me!

Adbot
ADBOT LOVES YOU

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Asymmetrikon posted:

because top level type inference is awful. leave inference where it belongs (lets inside a function) and be explicit with your interface

but ultimately every let is a let inside a function (main :: string array -> int) :smug:

  • Locked thread