The Loaf Question


Off-Topic Discussions

201 to 217 of 217 << first < prev | 1 | 2 | 3 | 4 | 5 | next > last >>

Gary, are you Loafing around?


He's busy baking you a trojan fruitcake filled with terracotta Cosmos to steal your hoard.


Ambrosia Slaad wrote:
He's busy baking you a trojan fruitcake filled with terracotta Cosmos to steal your hoard.

NOOOOOOOOOO!!!!! ~runs off to protect my hoard~


Sharoth wrote:
Ambrosia Slaad wrote:
He's busy baking you a trojan fruitcake filled with terracotta Cosmos to steal your hoard.
NOOOOOOOOOO!!!!! ~runs off to protect my hoard~

Exxxxxcellent! Release... the 501st NyanTroopers to invade Sharoth's workplace servers.


Nyan Cat wrote:
Sharoth wrote:
Ambrosia Slaad wrote:
He's busy baking you a trojan fruitcake filled with terracotta Cosmos to steal your hoard.
NOOOOOOOOOO!!!!! ~runs off to protect my hoard~
Exxxxxcellent! Release... the 501st NyanTroopers to invade Sharoth's workplace servers.

MEWWWWWWWWWWWWWWWW!!


So, in an effort to understand this, (and you can blame/thank Orthos for me resurrecting this thread) I'll try to apply my knowledge of C++ to this. Beginning with Post #1.

*Ahem*

class OExpandingLoaf;
class OPartialLoaf : public OExpandingLoaf;
class RegionLoaf : public OExpandingLoaf;
class OVirtualLoaf : public OExpandingLoaf;

class InnerLoaf;
class SplitLoaf : public InnerLoaf;
class DspLoaf : public InnerLoaf;

So, when we talk about loaves of a particular type becoming loaves of other types, we're talking about Polymorphism. Therefore

class OPartialLoaf : public OExpandingLoaf
{
public:

RegionLoaf OPartialLoaf::RegionLoaf();
SplitLoaf OPartialLoaf::SplitLoaf();
};

class OVirtualLoaf : public OExpandingLoaf
{
public:

RegionLoaf OVirtualLoaf::RegionLoaf();
SplitLoaf OVirtualLoaf::SplitLoaf();
};

class RegionLoaf : public OExpandingLoaf
{
public:

SplitLoaf RegionLoaf::SplitLoaf();
};

Is there anything wrong with my understanding of the problem thus far?


This is... amazing.


Post #1, part 2.

Gary Teter wrote:

Let's call it a LoafWrapper. Its job is to pretend that it's a Loaf that can "become" other kinds of Loafs. It does this by keeping a private Loaf no one else can see. When asked to do anything, it lets the private Loaf do all the work. (And get none of the credit!) When asked to become some other kind of Loaf, it gets a new private Loaf of the requested type, and unceremoniously dumps the old private Loaf onto the garbage heap. LoafWrapper's kind of a jerk, I suppose.

Here's the problem: The Loafs that can become a SplitLoaf (OPartialLoaf, OVirtualLoaf and RegionLoaf) are actually cousins of SplitLoaf instead of siblings. If LoafWrapper is a member of the RegionLoaf family, then it can't pretend to be a SplitLoaf -- they're not directly related.

What family should LoafWrapper be a part of?

LoafWrapper should be a union of all loaf types, such that

union ULoaf
{
class OPartialLoaf OPL;
class RegionLoaf RL;
class OVirtualLoaf OVL;
class SplitLoaf SL;
class DspLoaf DL;
};

This means that LoafWrapper inherits the properties of all loaf types, so that

class LoafWrapper : public ULoaf;

The private Loaf is a Union of all loaf types, and LoafWrapper is a set of copy constructors using operator= overloading, returning a pointer to the new loaf type before deleting the pointer to the old loaf type.

Thus,

class LoafWrapper : public ULoaf
{
private:
ULoaf Loaf;

public:
RegionLoaf operator=( OPartialLoaf );
SplitLoaf operator=( OPartialLoaf);
RegionLoaf operator=( OVirtualLoaf );
SplitLoaf operator=( OVirtualLoaf );
SplitLoaf operator=( RegionLoaf );
};

LoafWrapper should be untyped, as it's a collection of helper functions.

Is my understanding of the second part clear?


Post #7

Gary Teter wrote:

There are, of course, any number of ways to solve the Loaf question. Perhaps the LoafWrapper is inherently impossible. (I don't think so, but haven't determined whether it is yet. I'm lazy like that.)

So introduce a notification center. If you have a Loaf which might become another kind of Loaf, you tell the notification center you'd like to be notified when your Loaf becomes something else.

A Loaf, when asked to become another kind of Loaf, would then post a notification saying, "I was this Loaf, but now I'm this other Loaf." The notification center then informs everyone who was interested in that particular Loaf about the change. In response, you switch your reference to the original Loaf to the new Loaf.

This would work, but I don't think it's scalable. There are probably going to be millions of Loafs, and who knows if the notification center can handle that kind of burden?

(Now, given that the Loafs are part of the Ent, perhaps the notification center would be built using an Ent! Then it would be scalable, but in a weird way that makes my head spin.)

Ah. A new term. The Ent. A walking tree of long memory.

So now, LoafWrapper has a new public member called notification, which is a structure containing two members OldLoafType and NewLoafType, which are both short integers, so that

struct SNotification
{
short OldLoafType;
short NewLoafType;
};

and LoafWrapper becomes

class LoafWrapper : public ULoaf
{
private:
ULoaf Loaf;

public:
struct SNotification Notification;
RegionLoaf operator=( OPartialLoaf );
SplitLoaf operator=( OPartialLoaf);
RegionLoaf operator=( OVirtualLoaf );
SplitLoaf operator=( OVirtualLoaf );
SplitLoaf operator=( RegionLoaf );
};

The members of Notification are set by the copy constructors. When the program reads the values of Notification, both members are set to zero. The actual values held in OldLoafType and NewLoafType are implementation defined, and non-zero.

So an Ent would be an array or list with SNotification members, so that

struct SNotification Ent[MAX_INT]; // an arbitrary number, 2GB


1 person marked this as a favorite.

Taking a break from this effort for a while, so that I can think about the posts further down the line.


2 people marked this as a favorite.
John Napier 698 wrote:
Taking a break from this effort for a while, so that I can think about the posts further down the line.

So you're going to loaf around for a bit?

The Exchange

2 people marked this as a favorite.

Ba Dum Tish!


1 person marked this as a favorite.

Actually, no. There appears to be no more solid information from which I can produce C++ code. Everything else is just snarky humor or references to code for which I don't have the source to. I think I've gone as far as I can.

Paizo Employee Senior Software Developer

2 people marked this as a favorite.

I swear this thread does not describe the diagram on that whiteboard over there, nosirree, nope, nope.


4 people marked this as a favorite.

Excellent! Otherwise, that would be weird.

Goes back to intently building a loaf shape with mashed potatoes.


It's alive! It's alive!!!


captain yesterday wrote:

Excellent! Otherwise, that would be weird.

Goes back to intently building a loaf shape with mashed potatoes.

Mmmm, potato bread.

201 to 217 of 217 << first < prev | 1 | 2 | 3 | 4 | 5 | next > last >>
Community / Forums / Gamer Life / Off-Topic Discussions / The Loaf Question All Messageboards

Want to post a reply? Sign in.