Addition of code words, good or bad?
Displaying 1-20 of 20 total.
1
Overkill
|
I've been considering adding actual words for the logical operators:
// && = and
// || = or
// ! = not
if (player[i].possessed
|| (!player[i].dead && !player[i].unconcious))
{
}
if (player[i].possessed
or (not player[i].dead and not player[i].unconcious))
{
}
I'm sure that people who are weaker programmers might like these words, especially since they're much closer to English.
I've also been considering unless() and until() statements, which are basically if() and while() that execute when the condition is false. Sometimes it could mean conditionals that better explain themselves.
// You don't have the trinket, you get nagged.
if (!(found_legendary_trinket))
{
Textbox(
"You still haven't found it? Just be glad the gods didn't give " +
"me the power to walk off of this throne to smack you."
);
}
// You don't have the trinket, you get nagged.
unless (found_legendary_trinket)
{
Textbox(
"You still haven't found it? Just be glad the gods didn't give " +
"me the power to walk off of this throne to smack you."
);
}
...
while (!(done))
{
}
until (done)
{
}
Yeah, yeah. The nested brackets around a single conditional aren't necessary, but it would be necessary to make until/unless work. Either that, or reverse the behaviour of the compiled code's jumps, so it would go past the if()/while() when the condition was true, and go into the block when false. The latter would avoid the minor, minor effect of logical not on a statement inside brackets, but likely suffer slightly more complexity in the compiler.
So what says you people? Is this good to add more variety into the language by introducing new words, or should they be avoided?
Edited to not abuse preformatting. -Grue
Thanks. -Overkill
Posted on 2006-07-05 21:31:47 (last edited on 2006-07-05 22:17:55)
|
Gayo
|
I don't really consider it a priority, and I think there's a risk that adding too many variants that accomplish the same thing would actually make matters more confusing. Buuuut it'd probably be fine.
Posted on 2006-07-05 21:34:42
|
Omni
|
I find it pretty easy to just set my "code words" using #DEFINE tags. It's not exactly necessary to hardcode it...
Also. Isn't it possible to enact Unless() and Until() loops using different forms of If() and While() logic anyway?
Posted on 2006-07-05 21:34:43
|
mcgrue
|
Of course it's possible right now. I believe OVK's proposing constructs that are simple to implement and make the scripting code easier to read for the not-strictly-programmers out there who want to make games.
Which is an interesting idea which warrants consideration. Maybe if some new vergers spoke up on this subject, since all the regulars are jaded coder-types?
Posted on 2006-07-05 22:10:35
|
Overkill
|
I find it pretty easy to just set my "code words" using #DEFINE tags. It's not exactly necessary to hardcode it... Even though #define can be used this way, I dunno... But yeah, of course it's not necessary. However, I think verge1 and verge2 both had and/or words acceptable in conditionals, as evident in the the textpad syntax definition I have (which must have just copied the v2 syntax definition and added v3 functions).
Also. Isn't it possible to enact Unless() and Until() loops using different forms of If() and While() logic anyway? Yeah, basically just using the ! operator on the whole condition cluster.
I dunno, yeah I'm a bit conflicted too. But allowed variety occasionally makes cleaner code when used effectively. Although, when ineffectively used, code could possiby be worse, in a minor way (like mixing logical keywords with logical operators in a statement). But bad code is always bad code.
Posted on 2006-07-05 22:14:02 (last edited on 2006-07-05 22:14:30)
|
Overkill
|
While we're at it, how would people feel about the addition the builtin definitions for "true" and "false", even if it is pretty easy to do without or define it yourself?
Posted on 2006-07-05 23:18:19
|
Omni
|
Well, I suppose if you feel the urge to do so, it's not going to break the engine or anything like that.
Posted on 2006-07-06 14:50:07
|
jrhee
|
I don't think I'd much like adding "and" and "or"s and such. Personally I just think it's a bit of an eyesore, being used to looking at C and Java based syntax. For me, symbols helps distinguish keywords from operators when skimming code and just makes things easier to read overall. Besides, newbies should really be learning what those symbols mean if they intend to take coding seriously.
I do think adding true and false might be somewhat useful, though.
Posted on 2006-07-06 15:37:23
|
mcgrue
|
v1 had AND and OR.
And I recall them making my first little steps into programming very easy.
And having them certainly would not make the code less readable to experienced programmers.
Posted on 2006-07-06 19:06:01
|
mcgrue
|
What about making a NOT for ! as well, in the AND/OR lines?
Posted on 2006-07-07 17:22:28
|
Omni
|
Anybody who would type 'NOT' in place of a simple '!' when they know full well that both would do the same thing...
Well, I don't know about those people. Heck, in Python that even feels right. But I don't know about here. ...I _guess_ it wouldn't hurt.
Posted on 2006-07-07 18:24:41
|
Overkill
|
That was proposed in original post, so sure, why not (why !).
Posted on 2006-07-07 18:26:10
|
mcgrue
|
You could also add IS and ISNT as valid replacements for = and != along these lines. And then we'll be a step away from VergeSQL, which is man's oldest dream. >_>
Posted on 2006-07-08 02:17:39
|
Gayo
|
Oooh, someone should totally design a vc lib for interfacing with a MySQL server.
Also, someone should suck my dick.
Posted on 2006-07-08 06:24:37
|
mcgrue
|
Quote:Originally posted by Gayo
Oooh, someone should totally design a vc lib for interfacing with a MySQL server.
Also, someone should suck my dick.
Actually, using zeromus's plugin library, it'd be a trivial matter to build a module to interface with a SQL Server *OR* with an FUFME server...
...NOW IF HE'D ONLY MAKE THE GODDAMNED EXAMPLES TO SHOW THE REST OF US HOW GRR.
Posted on 2006-07-08 07:20:20
|
rpgking
|
As long as you're just adding these "code words" in and not replacing the logical operators, I see no problem with this. Those of us who are experienced can still stick to what we're used to, while others who are complete beginners may have an easier time with VergeC.
Posted on 2006-07-08 22:30:03
|
Overkill
|
Well no, I hadn't planned to have the keywords replace the existing logical operators, but rather give the user an alternative to symbols if they so chose.
Posted on 2006-07-08 22:47:18
|
Ioachim
|
VergeC should be kept C, you see?
No, really, adding redundant functionality... I don't think is a good idea. Maybe someone doing a VergeBasic or some other VergeSomeLanguage compiler to program in something else but using Verge engine (that just rembers me about CLR and .Net ).
But that probably would mean to separate the compiler form the engine (that doesn't seem a bad idea, anyway...)
Posted on 2006-09-04 13:54:31
|
Overkill
|
VergeC is not meant to be C, therefore it can have differences. One such difference could be the introduction of keywords which really don't hurt the syntax in order to make it slightly easier to pick up for new people. It isn't really redundant, it's an alternative syntax. It's simply making the compiler check for another keyword without hurting the internal execution of code at all.
Also, the compiler/interpretter already is separate from the engine. There's just a crapload of vc wrapper functions that are called by the interpretted code, which in turn call the actual engine functions.
Oh yeah, and added unless() / until().
Posted on 2006-09-04 14:10:05 (last edited on 2006-09-04 14:12:33)
|
adderd
|
My take is that you should be careful not to turn vergec into a giant circus complete with huge tent and clowns. There is such a thing as a syntax being too freeform.
I'm not totally sure whether I feel the proposed changes will get to the circus tent point or not. But personally I feel that a language should be kept as simple as possible. That means potentially not coming up with 95 different formats for writing the same thing.
I can see how the words approach would be a little easier for a beginner but I'm not a huge fan of ballooning a language. Wouldn't stand in the way of other people doing it but I can't say I like it.
Posted on 2006-09-04 20:31:20
|