C*
- This is still a work in progress. It may be changed in the future.
C* or Cx, pronounced "C Times", is a concept for an extension of the C++ programming language by User:H33T33.
Semicolons
Semicolons are no longer a requirement for representing newlines.
Outputting
Outputting and Inputting have been slightly tweaked to be more convenient.
It mimics Python's "print" method as well as providing an option for automatically moving to the next line (println)
Single Values
Parentheses are optional when outputting single values and variables.
println("Hello,")
print "world!"
Multiple Values
If, however, the given value is a variable or there is more than one value, then printing will better resemble C's style of outputting.
println("%s",var1)
print("%s %d",var2, var3)
Inputting
int var input(var)
input resembles Python while functioning similarly to C.
Variables
var = 0
A variable does not require a data type when defined if it is given a value.
If Statements
If Statements are unchanged.
if(condition1){
println("abc")
}else if(condition2){
println("def")
}else{
println("ghi")
}
Functions
Typically, every value must be given a predetermined data type. While that is still a requirement in C*, that only applies to variables. Functions don't need to be given a return type as long as they return a value, in which case it will inherit the value's data type.
func1(){
println("abc")
}
func2(){
return 'd'
}
In the above code, two functions are declared: func1 and func2. func1 prints but does not return, so it is assigned a void type.
func2 does return a value and will therefore be assigned the value's data type. In this case, the char type is assigned. Because of this, a single function can return multiple different data types.
For example:
func1(int param){
if(param<0){
return 0
}else if(param>0){
return 'a'
}else{
return "bcd"
}
}
If a given parameter is less than 0, func1 returns 0 and is then "redefined" with an integer return type.
If the parameter is more than 0, func1 returns 'a' and is "redefined" with a character return type.
If neither of the conditions is true, then it returns "bcd" and is "redefined" as a string/character pointer.
Loops
For
For Loops are just like C++ except, unless otherwise specified, it is assumed that the variable should be incremented by 1.
Assumed Increment
for(i=0; i<10){
println(i)
}
Specified Increment
for(i=0; i<10; i++){
println(i)
}
Specified Increment (Obscure)
This will probably be the least used form of a For loop. It uses what I call "obscure incrementation" even though it's using a variable by name.
for(i=0; i<10; 1){
println(i)
}
"Obscure incrementation" (assuming it isn't already a thing) is when the number a loop iterates by is represented as a literal integer rather than variable manipulation.
Assumed Increment (No Variable)
In fact, variables aren't necessary at all! All it really needs is to know how many times it should loop!
for(10){
println("abc")
}
Specified Increment (No Variable + Obscure)
With no variable, obscure incrementation is the only way to increment.
for(10; 1){
println("abc")
}
While/Do-While
While
While Loops are unchanged. The loop runs for as long as a given condition is true.
while(true){
println("abc")
}
Do-Whiles, on the other hand, have one small change. They're just like regular While loops, but the condition is placed after the While loop. The condition is checked after a single iteration of the loop has completed.
Do-While
while{
println("abc")
}(true)
Other
This is just where most unchanged and smaller features will be shown.
Logical Operators
Logical operators remain the same.
OR
Represented by ||. It takes two values and returns true if either are non-zero or true. It otherwise returns false.
AND
Represented by &&. It takes two values and returns true both are non-zero or true. It otherwise returns false.
NOT
Represented by !. If a value is true then it is turned false, and vice versa.
For example, !true is not true, so it is false.