death to case sensitivity !

Started by meems, February 28, 2018, 20:31:37

Previous topic - Next topic

meems

@Matty
>shows me that zome of the thoughts expressed never make it to industry
> implying that if syntaxbombers have a good idea, we can get it into industry languages in under 6 weeks

Sadly, you think too highly of us. If you are expecting us to get our better ideas into Java 10 and C# 7.4 then you're going to be disappointed. I'm flattered , hey, I know I'm ace, and I don't need anyone to tell me, but its best you understand I'm not the CEO or lead dev at Oracle or Microsoft.

iWasAdam

Me... I like to instantly see what the code is telling me. so I use the following:
methods/functions = CamelCase
local variables = lowerCase
class variables _lowerCase
constants = UPPER_CASE

other variables name exist - you then have to hunt for were they are set. if not local then check the private then protected then public areas. After that... phone home and ask for help ;)


Derron

@ adam
you prefix all class variables with "_" underscore? I would have assumed people use it to define them as "private properties" (if the language does not offer a "private/public" portion in classes/types).

Else I use exactly the same (ok, had a time with "set***()" and "get***()" being written lowerCamelCase too ... dunno why)


bye
Ron

Xaron

Here at work we use _variableName for all class members as well. That way you instantly see what's a member and what's not. It's in our coding guideline (plus tabs to spaces as well! :) ) Oh, we use C++ here. What a beast!

col

QuoteHere at work we use _variableName for all class members as well.
QuoteOh, we use C++ here

I'm sure you're waiting for this already so I'll bite :)
In the C++ coding standard it states
Quote"Don't overlegislate naming, but do use a consistent naming convention: There are only two must-dos: a) never use "underhanded names," ones that begin with an underscore or that contain a double underscore;"
(p2 , C++ Coding Standards, Herb Sutter and Andrei Alexandrescu).

I usually use the underscore style in BMax for private variables, but in C++ I generally use m_ for member variables and g_ for globals.

https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

Xaron

Haha good one and I tend to agree. But... I can't do anything about it here.

Steve Elliott

Quote
Me... I like to instantly see what the code is telling me. so I use the following:

methods/functions = CamelCase

Don't Mark's languages precede methods/functions with either the word method or function?  So that tells you what it is lol.  I guess you're talking about *calling* a method/function.  Even then is a distinction really necessary as methods/functions are followed by brackets which indicates a method/function, rather than a variable name?

Quote
local variables = lowerCase

class variables _lowerCase

What is the difference here Adam?  Class variables are member variables and a class should be a self contained unit, with data passed-in if appropriate.

And yes, col's correct when using C++ - do not use underscores to precede a variable's name.



Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Derron

> Even then is a distinction really necessary as methods/functions are followed by brackets which indicates a method/function, rather than a variable name?


function MyVar:int()
return 10
end function

print myvar * 10

Steve Elliott

#53
Fair point.   :)

But shouldn't it be print MyVar() * 10
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Derron

it should - but it isn't needed (at least in BlitzMax) - at least not in call cases.

above's example btw fails:
Compile Error: Types 'Int(Int)' and 'Int' are unrelated

bye
Ron

Steve Elliott

Then it's the language that is at fault, leading to people having to clarify using case sensitivity.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Matty

Mine is simple.

Everything in lowercase except constants which are all caps.

iWasAdam

@Steve
With monkey you have properties - that are sort of like variables but can also do lots of other stuff too.
e.g.

Class Channel
Method New()
End

Property Stereo:bool()
Return _stereo
Setter( stereo:bool )
_stereo = stereo
End

private
field _stereo:bool = False
End Class

Local myChannel =  New Channel
myChannel.Stereo = true
Print myChannel.Stereo


_stereo is private and we cant access it
but with setters and properies we can both set and see what it is - we can also add other code in these too...

But <WARNING> You must watch the cases and what variables you are dealing with in the properties and setters. otherwise it will all go Pete Tong!

Steve Elliott

Quote
But <WARNING> You must watch the cases and what variables you are dealing with in the properties and setters. otherwise it will all go Pete Tong!

So it's Mark's Monkey Madness then lol.   :P
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

iWasAdam

yep. wait a minute.... thinks and looks at really old blitzmax code
Yep using _ as the first character is definitely a monkey2 Mark thing  :))

interesting to note that it is 'illegal' in c++ to do it (which is what monkey2 compiles into).