New around here? Register your SA Forums Account here!

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.
 
  • Post
  • Reply
distortion park
Apr 25, 2011


the superior vcs (hg) solves the rewrite issue but marking commits as unpublished or published. As long as you don't push your history you can rewrite it but after that it's much more restrictive.


(there's also a 3rd "don't push this commit" state to make it easy to manage wip stuff)

Adbot
ADBOT LOVES YOU

TheFluff
Dec 13, 2006

FRIENDS, LISTEN TO ME
I AM A SEAGULL
OF WEALTH AND TASTE

Luigi Thirty posted:

you write one template function in C++ and suddenly your whole world is internal compiler errors when it breaks
tiny brain: uses preprocessor macros as poor man's generics
ascended brain: uses C++ templates for generics
galaxy brain:
code:
#define BUILDER_MEMBER(type, name) \
  template <class T> \
  auto set_##name(T &&val) -> decltype(*this) { name = std::forward<T>(val); return *this; } \
  type name;

Luigi Thirty
Apr 30, 2006

Emergency confection port.

n-nooooooo

I'm trying to do horrible things in C++

I have two classes, Texture and Model3D. they inherit from an abstract base class/interface IHasName which defines a virtual IsNamed search predicate for lookups which the classes implement.

I keep track of textures and models in two vector<IHasName *> containers with a template function FindInVectorByName that converts the pointers to the correct type before returning the search result, i.e. you call FindInVectorByName<Texture>(vector_of_textures, "poop") and it returns a Texture *

I know you can't directly cast IHasName * to Model3D * or Texture * but I'd like to enforce type-safety on my vectors so I don't end up with textures in my model vector if I gently caress up somewhere. this seems like a bad way of doing things.

I need a C++ scholar here to tell me how to do this correctly because I think this is a terrible programming and I'm ready to move to Belize

Luigi Thirty fucked around with this message at 13:52 on Sep 7, 2018

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
cjs: well, I'm hosed.

In Go, I'm consuming JSON data off a websocket. This data has a price field that is a decimal with fractions of pennies, so could be -0.000345 or whatever. Go does not have a decimal type in stdlib. So, now I have to basically roll-my-own JSON parser so I can get this loving value into my (third-party) decimal type field without having to drop it into a float and lose precision.

Now, you might be wondering if there is some means to override parts of the JSON parser to handle this particular field with special fixed-precision kidgloves, and there is, but it won't let me parse a number field as a string. It returns an error in that case. Thus, I'm back to re-implementing JSON parsing.

Calgon, take me away...

Lime
Jul 20, 2004

if you want a vector that only has Textures in it then make it a vector<Texture*>?? FindInVectorByName already has some template parameter T so just make its first function parameter a vector<T*> instead of a vector<IHasName*>

if you really insist on not knowing what's in your vector then you're going to have to use dynamic_cast and just eat the associated cost

Zlodo
Nov 24, 2006

Luigi Thirty posted:

n-nooooooo

I'm trying to do horrible things in C++

I have two classes, Texture and Model3D. they inherit from an abstract base class/interface IHasName which defines a virtual IsNamed search predicate for lookups which the classes implement.

I keep track of textures and models in two vector<IHasName *> containers with a template function FindInVectorByName that converts the pointers to the correct type before returning the search result, i.e. you call FindInVectorByName<Texture>(vector_of_textures, "poop") and it returns a Texture *

I know you can't directly cast IHasName * to Model3D * or Texture * but I'd like to enforce type-safety on my vectors so I don't end up with textures in my model vector if I gently caress up somewhere. this seems like a bad way of doing things.

I need a C++ scholar here to tell me how to do this correctly because I think this is a terrible programming and I'm ready to move to Belize

You don't need the interface to do this because FindInVectorByName already knows the type.
This could look like this:

class Texture
{
// your IsNamed predicate here, not virtual
};

class Model3d
{
// your IsNamed predicate here, also not virtual
};

template< typename T >
const T* FindInVectorByName< const vector< T >& myVec, const char* myName )
{
// iterate through myvec, call IsNamed to find if it's what you're looking for
}

Zlodo fucked around with this message at 14:32 on Sep 7, 2018

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 9 years!)

Zlodo posted:

You don't need the interface to do this because FindInVectorByName alrady knows the type.
Here's a possible solution:

class Texture
{

}

please don't post java

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Lime posted:

if you want a vector that only has Textures in it then make it a vector<Texture*>?? FindInVectorByName already has some template parameter T so just make its first function parameter a vector<T*> instead of a vector<IHasName*>

if you really insist on not knowing what's in your vector then you're going to have to use dynamic_cast and just eat the associated cost

knowing what's in my vectors would be nice

Zlodo posted:

You don't need the interface to do this because FindInVectorByName already knows the type.
This could look like this:

class Texture
{
// your IsNamed predicate here, not virtual
};

class Model3d
{
// your IsNamed predicate here, also not virtual
};

template< typename T >
const T* FindInVectorByName< const vector< T >& myVec, const char* myName )
{
// iterate through myvec, call IsNamed to find if it's what you're looking for
}

doh ok I don't need the interface at all thanks

Shaggar
Apr 26, 2006

Finster Dexter posted:

Go does not have a decimal type in stdlib.

what?

anthonypants
May 6, 2007

by Nyc_Tattoo
Dinosaur Gum
https://github.com/golang/go/issues/12127

tef
May 30, 2004

-> some l-system crap ->

brap posted:

can someone explain to me how a commit gets "lost" in git because that has never happened to me

i have had to pull poo poo out of the reflog before but that does not mean anything was lost.

work in detached head mode or break a rebase

tef
May 30, 2004

-> some l-system crap ->
people who're talking about what people *should* and *shouldn't* do with a vcs is lovely please never design anything

'why would you need to do this thing, it works on my machine'

that's great shut up

like you need some history rewriting ability because people commit poo poo that *should* not have been committed and has to be purged, you loving muppets

Fiedler
Jun 29, 2002

I, for one, welcome our new mouse overlords.

Finster Dexter posted:

In Go, I'm consuming JSON data off a websocket.

why are you wasting time with this when you should be converting to .Net?

tef
May 30, 2004

-> some l-system crap ->
then the complete ignorance of 'well dont commit those wip commits' i am sorry i'm using a version control system

like at the point where you'e not doing an OT model and merging keystrokes you're already lying about the history

what gives

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
or if you push a branch and it never gets merged you're not allowed to delete it ever because that's rewriting history.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
anyhow i bought a game engine architecture book and a linear algebra book and i'm enjoying both. i think i'm going to use opengl to draw graphs of the linear algebra stuff i'm learning.

CPColin
Sep 9, 2003

Big ol' smile.
Back at a previous job, I had a real conflict of interest with myself between people who would be out sick on the last day of a sprint and hadn't pushed their latest changes vs. people who endlessly did "WIP" and "fix" commits and made blames completely worthless. And stupid BitBucket didn't have a "squash and merge" button on PR's, like GitHub does.

Really, though, a lot of the problem was the dogma that everything always had to be released at the end of the sprint and nobody ever just bumped a ticket in the event of an illness or whatever. Still, it just made PR's loving complicated.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
rewriting history on master should absolutely not be part of your normal workflow. if someone pushes some sensitive information that shouldn't be there, there should be a way to remove it, but it should involve contacting someone who administers the server, and also writing a retrospective on how that sensitive information got there to begin with and what process changes can be made to prevent a similar fuckup from happening in the future.

do whatever you like on your local vcs, though. that one's yours. the thing everyone else cares about is what commits you're pushing to master, which should absolutely not be your half-broken wip commits

MononcQc
May 29, 2007

I like mercurial's approach of tracking what is a public and a private repository (or branches) and only allowing rewrite on stuff that is not marked as public (in order to avoid breaking the workflow of others)

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

MononcQc posted:

I like mercurial's approach of tracking what is a public and a private repository (or branches) and only allowing rewrite on stuff that is not marked as public (in order to avoid breaking the workflow of others)

yeah that sounds real good, would like that in git.

raminasi
Jan 25, 2005

a last drink with no ice
but don’t you want to be able to see my ~~workflow~~?

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

DONT THREAD ON ME posted:

yeah that sounds real good, would like that in git.

depending on your remote backend, you can disable force pushes for specific branches

Powerful Two-Hander
Mar 9, 2004

Mods please change my name to "Tooter Skeleton" TIA.


hi its me, I'm the guy making GBS threads up the history with all his individual commits because idgaf

i am a trash man
squash em all 2018 etc etc.

tef
May 30, 2004

-> some l-system crap ->
i found out git headers are a great way to smuggle information about because they're pretty much unseen in all of the tooling

Shaggar
Apr 26, 2006

incredible. why does anyone use go?

Toady
Jan 12, 2009

MononcQc posted:

I like mercurial's approach of tracking what is a public and a private repository (or branches) and only allowing rewrite on stuff that is not marked as public (in order to avoid breaking the workflow of others)

mercurial was the first distributed version control i used, and it was pleasant, and i was bummed when git exploded in popularity. i've learned the core commands i need to get work done with git, but once in a while, i have to deal with its complexity, and it's such a time-waster trying to figure it out

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
for me most of gits shittiness comes from the fact that I have two dev machines since I work from home regularly. long lived branches can be ugly to manage if I work on them on both machines a few times.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 9 years!)

jit bull transpile posted:

for me most of gits shittiness comes from the fact that I have two dev machines since I work from home regularly. long lived branches can be ugly to manage if I work on them on both machines a few times.

i've gotten to the point where i push just about everything to my personal fork of the relevant repo, so syncing to another system is just a git pull

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

carry on then posted:

i've gotten to the point where i push just about everything to my personal fork of the relevant repo, so syncing to another system is just a git pull

same, but sometimes one of my machines will just start refusing to recognize there's new commits to pull and I have to do voodoo to get it working again.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

jit bull transpile posted:

same, but sometimes one of my machines will just start refusing to recognize there's new commits to pull and I have to do voodoo to get it working again.

try installing a glide wrapper

pseudorandom name
May 6, 2007

Shaggar posted:

incredible. why does anyone use go?

C++ doesn't have a decimal type either

Progressive JPEG
Feb 19, 2003

Finster Dexter posted:

cjs: well, I'm hosed.

In Go, I'm consuming JSON data off a websocket. This data has a price field that is a decimal with fractions of pennies, so could be -0.000345 or whatever. Go does not have a decimal type in stdlib. So, now I have to basically roll-my-own JSON parser so I can get this loving value into my (third-party) decimal type field without having to drop it into a float and lose precision.

Now, you might be wondering if there is some means to override parts of the JSON parser to handle this particular field with special fixed-precision kidgloves, and there is, but it won't let me parse a number field as a string. It returns an error in that case. Thus, I'm back to re-implementing JSON parsing.

Calgon, take me away...

?

Spime Wrangler
Feb 23, 2003

Because we can.

Luigi Thirty posted:

try installing a glide wrapper

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Luigi Thirty posted:

try installing a glide wrapper

I'm not loving the computer..
why would I need a lubricated condom?

gonadic io
Feb 16, 2011

>>=

Luigi Thirty posted:

try installing a glide wrapper

I didn't realise we were in the velocity thread

suffix
Jul 27, 2013

Wheeee!

love the key feature of skein

Slurps Mad Rips
Jan 25, 2009

There's No Guarantee

Luigi Thirty posted:

knowing what's in my vectors would be nice


doh ok I don't need the interface at all thanks

also, for future reference, when working with base classes, you can use dynamic_cast and the if assign approach to enter specific type blocks (as long as you know all the types or don't care about anything but one or two)

Something like this if you're stuck with msvc 6
C++ code:
struct Base { virtual ~Base() = default; };
struct Derived1 : Base { };
struct Derived2 : Base { };

void function (Base* ptr) {
  if (Derived1* d = dynamic_cast<Derived1*>(ptr)) {
    // do a thing here
  } else if (Derived2* d = dynamic_cast<Derived*>(ptr)) {
    // do a different thing here
  } else {
    // this is your fallback state in case additional classes are added in the future.
  }
}

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER


pseudorandom name posted:

C++ doesn't have a decimal type either

SQL does

and the guy who set up the SQL server at work used the type to produce large zero precision numbers, i.e. numbers with up to 18 decimals, with none after the decimal place.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

apparently I compiled stlport without RTTI lol, rip _cast functions

I’ll rebuild it with RTTI and see if it works

Adbot
ADBOT LOVES YOU

suffix
Jul 27, 2013

Wheeee!

redleader posted:

i've heard people say poo poo like "history should be immutable because if i'm chasing a bug i need to ~understand the thought process~ that the original developer went through. if they rewrite history, i won't be able to read the total history to ~understand~ how the bug was introduced". you haven't ever done or needed to do this, gently caress you

i have definitely been annoyed before irl at giant squashed "add feature x" commits that touch 300 files, because i was trying to figure out why line n changed, and it was very likely a "oh bar needs to be baz now because the frobnicator failed when i ran the tests" commit originally
remove the wip garbage commits if you must but ffs merge don't squash and rebase

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply