Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 580 581 [582] 583 584 ... 796

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

XXXXYYYY

  • Bay Watcher
  • Been a long time.
    • View Profile
Re: if(isCoder(Pseudo), post()) #Programming Thread
« Reply #8715 on: December 17, 2015, 05:22:31 pm »

is java even regular

Generalizations and all that but no programming languages are regular.
Not quite true.

Black, for example, is just { |#|\n}* (where \n represents a newline and # represents any non-whitespace character (I didn't want to write them all in, and it's not like it matters syntactically anyway, as they're all treated identically)).
I'm pretty sure it qualifies, as the rule for it is just a couple unions and a Kleene star of the three regular languages (as they are singletons) { }, {#}, and {\n}, which I'm pretty sure means it in turn is a regular language.

I mean, it's not very useful, but it is still technically a programming language, even if an esoteric one.

Though I'm just being kinda pedantic, so it's safe to disregard me.
« Last Edit: December 17, 2015, 05:24:33 pm by XXXXYYYY »
Logged
Oooooooo. I know. ClF3. That should be a fun surprise.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #8716 on: December 17, 2015, 10:39:35 pm »

Reminds me of a snippet from a login;logout article..

it went along the lines if

Quote
l. Here’s a life tip: when you’re confused about what
something is, DON’T EXECUTE IT TO DISCOVER MORE
CLUES. This is like observing that your next-door neighbor
is a creepy, bedraggled man with weird eyes, and then you start
falling asleep on his doorstep using a chloroform rag as a pillow,
just to make sure that he’s not going to tie you to a radiator and
force you to paint tiny figurines. Here’s how your life story ends:
YOU ARE A PAINTER OF TINY FIGURINES.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Dutrius

  • Bay Watcher
  • No longer extremely unavailable!
    • View Profile
    • Arcanus Technica
Re: if self.isCoder(): post() #Programming Thread
« Reply #8717 on: December 19, 2015, 09:45:11 am »

Does anyone know if you can use get and set properties on arrays in C#?

Infact, can use use get and set on enumerations as well?
« Last Edit: December 19, 2015, 11:02:24 am by Dutrius »
Logged
No longer extremely unavailable!
Sig text
ArcTech: Incursus. On hold indefinitely.

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8718 on: December 19, 2015, 12:35:56 pm »

Does anyone know if you can use get and set properties on arrays in C#?

Infact, can use use get and set on enumerations as well?
What do you mean? Are you overriding an array? Otherwise no, you shouldn't set the properties that I can think of. It would help to see what you're trying to do.

Enumerations aren't a datatype with instances. It's just a list of acceptable values for a certain artificial type, usually just aliases and typechecking sugar for constants.

Dutrius

  • Bay Watcher
  • No longer extremely unavailable!
    • View Profile
    • Arcanus Technica
Re: if self.isCoder(): post() #Programming Thread
« Reply #8719 on: December 19, 2015, 12:46:55 pm »

Does anyone know if you can use get and set properties on arrays in C#?

Infact, can use use get and set on enumerations as well?
What do you mean? Are you overriding an array? Otherwise no, you shouldn't set the properties that I can think of. It would help to see what you're trying to do.

Enumerations aren't a datatype with instances. It's just a list of acceptable values for a certain artificial type, usually just aliases and typechecking sugar for constants.

Fair enough. Just wanted to see if I could use getters and setters instead of writing regular methods to do it.
Logged
No longer extremely unavailable!
Sig text
ArcTech: Incursus. On hold indefinitely.

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8720 on: December 19, 2015, 02:07:20 pm »

You can override the [] operator, and you can have an accessor that returns an entire array, but you can't have an accessor that takes an index.

So if you have a class foo, you can define a foo[3] or a foo.array that returns an entire array, but you can't have foo.bar[2] and put your own separate logic for that.

You can have multiple [] operators though if each takes a different type. I use that for my stuff, where foo[int] and foo[string] work differently.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8721 on: December 19, 2015, 02:34:37 pm »

In C# enumerations are in fact treated like a data type, they're just an int obviously under the hood but making instances of them is how you roll in C#. So they should have the same get;set; interface as any other variable.

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8722 on: December 20, 2015, 04:24:37 pm »

In C# enumerations are in fact treated like a data type, they're just an int obviously under the hood but making instances of them is how you roll in C#. So they should have the same get;set; interface as any other variable.


I believe you are thinking about Java. Otherwise Microsoft doesn't know about it


Unless of course, you happen to mean that you can set instances of the enums, which wasn't what I responded to.
« Last Edit: December 20, 2015, 04:51:57 pm by jaked122 »
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8723 on: December 20, 2015, 07:57:20 pm »

"Enumerations aren't a datatype with instances."

Is what you wrote, and what I responded to. Well, they are as much a datatype with instances as other primitive types are, and the rules are basically the same with getters/setters for them, so you can make an enum, create an instance of that in your class and use get/set:

Code: [Select]
public class Date
{
    public enum Months
    {
        jan, feb, mar, etc
    }
public class Date
{
    public enum Months
    {
        jan, feb, mar, etc
    }

    public Months month { get; set; } = Months.jan;
}

}

Which seems perfectly acceptable behavior. You'd write e.g. "date.month = Months.feb" to set the date.
« Last Edit: December 20, 2015, 08:41:16 pm by Reelya »
Logged

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8724 on: December 20, 2015, 08:38:26 pm »

I meant that they don't have properties like those in java. You're right. They do have instances, but they are not reference based, like those in java, but instead primitives.


You are correct, I think I misunderstood.

Dutrius

  • Bay Watcher
  • No longer extremely unavailable!
    • View Profile
    • Arcanus Technica
Re: if self.isCoder(): post() #Programming Thread
« Reply #8725 on: December 20, 2015, 08:42:21 pm »

"Enumerations aren't a datatype with instances."

Is what you wrote, and what I responded to. Well, they are as much a datatype with instances as other primitive types are, and the rules are basically the same with getters/setters for them, so you can make an enum, create an instance of that in your class and use get/set:

Code: [Select]
public class Date
{
    public enum Months
    {
        jan, feb, mar, etc
    }
public class Date
{
    public enum Months
    {
        jan, feb, mar, etc
    }

    public Months month { get; set; } = Months.jan;
}

}

Which seems perfectly acceptable behavior. You'd write e.g. "date.month = Months.feb" to set the date.

Thanks. This was exactly what I wanted to know.
Logged
No longer extremely unavailable!
Sig text
ArcTech: Incursus. On hold indefinitely.

Shadowlord

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8726 on: December 20, 2015, 08:48:53 pm »

P.S. You can also write

Code: [Select]
public Months month { get; private set; } = Months.jan;

Then only that class can use the setter. Or, use protected, and subclasses can use it too.
Logged
<Dakkan> There are human laws, and then there are laws of physics. I don't bike in the city because of the second.
Dwarf Fortress Map Archive

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8727 on: December 25, 2015, 09:41:25 pm »

Finished my C++ class with a..C. I have to say I'm not sure if I earned it after bombing two tests towards the end but what I get is what I get.

I'd like to give this to all those who helped me and pray to a merry christmas to all.


NOTE: SPOILER tag leads to another site but it should show an adorable dog with a sign.
Logged

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #8728 on: December 25, 2015, 10:22:15 pm »

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.

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #8729 on: January 07, 2016, 05:25:14 pm »

Man, it's surprisingly hard to add following behavior for entities pathfinding on a connected graph. Each node on the graph can only hold one entity, so when the entities are pathfinding I need to set nodes which already contain entities as impassible. This means that an entity which is trying to follow one node behind another keeps "bumping into it", but only if the following entity takes its turn before the followed entity.

The obvious solution is to set an entity's current node to passable if it's going to be moving this turn, but whether an entity will move could depend entirely on a third entity which may or may not block its path depending on whether that entity has moved already and AUGH

This is reminding me of network programming
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU
Pages: 1 ... 580 581 [582] 583 584 ... 796