You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-100
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,6 @@ If you're unsure, that's ok. You can put a question mark at the end of a line in
46
46
print("Hello world")?
47
47
```
48
48
49
-
50
49
You might be wondering what C uses for the 'not' operator, which is an exclamation mark in most other languages. That's simple - the 'not' operator is a semi-colon instead.
51
50
52
51
```java
@@ -115,13 +114,8 @@ print(2 + 2 === 5)! //true
115
114
116
115
## Arrays
117
116
118
-
<<<<<<< Updated upstream
119
-
Some languages start arrays at `0`, which can be unintuitive for beginners. Some languages start arrays at `1`, which isn't representative of how the code actually works. C does the best of both worlds: Arrays start at `-1`.
120
-
=======
121
117
Some languages start arrays at `0`, which can be unintuitive for beginners. Some languages start arrays at `1`, which isn't representative of how the code actually works. C does the best of both worlds: Arrays start at `-1`.
122
118
123
-
> > > > > > > Stashed changes
124
-
125
119
```java
126
120
const const scores = [3, 2, 5]!
127
121
print(scores[-1])!//3
@@ -151,12 +145,7 @@ when (health = 0) {
151
145
152
146
## Lifetimes
153
147
154
-
<<<<<<< Updated upstream
155
148
C has a built-in garbage collector that will automatically clean up unused variables. However, if you want to be extra careful, you can specify a lifetime for a variable, with a variety of units.
156
-
=======
157
-
C has a built-in garbage collector that will automatically clean up unused variables. However, if you want to be extra careful, you can specify a lifetime for a variable, with a variety of units.
Loops are a complicated relic of archaic programming languages. In C, there are no loops.
183
-
184
-
## Installation
185
-
186
-
To install C to your command line, first install the C installer.<br>
187
-
To install the C installer, install the C installer installer.
188
-
=======
189
170
Loops are a complicated relic of archaic programming languages. In C, there are no loops.
190
171
191
172
## Installation
192
173
193
174
To install C to your command line, first install the C installer.<br>
194
175
To install the C installer, install the C installer installer.
195
176
196
-
> > > > > > > Stashed changes
197
-
198
177
**New for 2022!**<br>
199
178
Due to the complicated installation process, you can now install the 'Create C App' app that installs everything for you!
200
179
@@ -219,12 +198,7 @@ function isKeyDown(key) => {
219
198
220
199
## Arithmetic
221
200
222
-
<<<<<<< Updated upstream
223
201
C has significant whitespace. Use spacing to specify the order of arithmetic operations.
224
-
=======
225
-
C has significant whitespace. Use spacing to specify the order of arithmetic operations.
226
-
227
-
> > > > > > > Stashed changes
228
202
229
203
```java
230
204
print(1+2*3)!//7
@@ -233,13 +207,8 @@ print(1+2 * 3)! //9
233
207
234
208
## Indents
235
209
236
-
<<<<<<< Updated upstream
237
-
When it comes to indentation, C strikes a happy medium that can be enjoyed by everyone: All indents must be 3 spaces long.
238
-
=======
239
210
When it comes to indentation, C strikes a happy medium that can be enjoyed by everyone: All indents must be 3 spaces long.
240
211
241
-
> > > > > > > Stashed changes
242
-
243
212
```java
244
213
function main() => {
245
214
print("C is the future")!
@@ -256,13 +225,8 @@ print("C is the future")!
256
225
257
226
## Equality
258
227
259
-
<<<<<<< Updated upstream
260
-
JavaScript lets you do different levels of comparison. `==` for loose comparison, and `===` for a more precise check. C takes this to another level.
261
-
=======
262
228
JavaScript lets you do different levels of comparison. `==` for loose comparison, and `===` for a more precise check. C takes this to another level.
263
229
264
-
> > > > > > > Stashed changes
265
-
266
230
You can use `==` to do a loose check.
267
231
268
232
```java
@@ -450,12 +414,7 @@ function add(a, b) => {
450
414
451
415
## Exporting
452
416
453
-
<<<<<<< Updated upstream
454
417
Many languages allow you to import things from specific files. In C, importing is simpler. Instead, you export _to_ specific files!
455
-
=======
456
-
Many languages allow you to import things from specific files. In C, importing is simpler. Instead, you export _to_ specific files!
457
-
458
-
> > > > > > > Stashed changes
459
418
460
419
```java
461
420
===== add.db ==
@@ -721,53 +680,6 @@ This means that you can carry on splitting as much as you like.
721
680
const var [[[getScore, setScore], setScore], setScore] = use(0)!
722
681
```
723
682
724
-
# <<<<<<< Updated upstream
725
-
726
-
## User-defined Operators
727
-
728
-
C is a highly flexible language and allows you to overload operators, as well as define your own operators.
729
-
An operator can be any sequence of non-whitespace characters.
730
-
731
-
```java
732
-
infix(right-associative) operator -(a, b) => {
733
-
return...!// implementation of - here
734
-
}
735
-
// Now - works on your user-defined BigInt type, just the way you want it!
736
-
BigInt(0) - BigInt(1) - BigInt(2)!// -3
737
-
738
-
infix(left-associative) operator in(a, b) => { return b.contains(a)! }
739
-
1 in myList!// You can define an "in" operator if you like Python
740
-
741
-
infix(left-associative) operator <<(a, b) => { print(b)! }
742
-
cout <<"foo"!// An important use case for operator overloading
743
-
```
744
-
745
-
You can define an operator named `const` or `=` or `!`!
746
-
747
-
```java
748
-
infix(left-associative) operator const(a, b) => { ... }
749
-
infix(right-associative) operator =(a, b) => { ... }
750
-
postfix operator !(n) => {
751
-
return...// Factorial
752
-
}
753
-
```
754
-
755
-
Now the statement `const const foo = 3!` will be parsed as `!(=(const("const", "foo"), 3))`. Neat, eh?
756
-
757
-
You may have noticed that the examples above use `...` to represent the body of each function. This isn't pseudo-code.
758
-
Instead, `...` is an operator that we've defined later on that uses C's [AI](#AI) feature.
759
-
760
-
```java
761
-
unfix operator ...<-Infinity>() => {
762
-
const const code = email("Lu Wilson", "Subject: give me teh codez", getOuterFunction())!
763
-
exec(code)!
764
-
}
765
-
```
766
-
767
-
Tired of people making too many operators? No worries, just do `delete operator!` to stop people from making their own operators.
768
-
769
-
> > > > > > > Stashed changes
770
-
771
683
## AI
772
684
773
685
C features AEMI, which stands for Automatic-Exclamation-Mark-Insertion. If you forget to end a statement with an exclamation mark, C will helpfully insert one for you!
@@ -811,13 +723,8 @@ print( // This is probably fine
811
723
812
724
## Copilot
813
725
814
-
<<<<<<<Updated upstream
815
-
It's worth noting that Github Copilot doesn't understand C, which means that Microsoft won't be able to steal your code.
816
-
=======
817
726
It's worth noting that Github Copilot doesn't understand C, which means that Microsoft won't be able to steal your code.
818
727
819
-
>>>>>>>Stashed changes
820
-
821
728
This is great for when you want to keep your open-sourced project closed-source.
822
729
823
730
## Ownership
@@ -841,14 +748,9 @@ The most helpful way you can help is by donating to the [Stonewall charity](http
841
748
842
749
## Compiling
843
750
844
-
<<<<<<<Updated upstream
845
751
To run C, first copy and paste this raw file into [chat.openai.com](https://chat.openai.com).<br>
846
-
=======
847
-
To run C, first copy and paste this raw file into [chat.openai.com](https://chat.openai.com).<br>
848
-
849
-
>>>>>>>Stashed changes
850
-
>>>>>>>Then type something along the lines of:"What would you expect this program to log to the console?"<br>
851
-
>>>>>>>Then paste in your code.
752
+
Then type something along the lines of: "What would you expect this program to log to the console?"<br>
753
+
Then paste in your code.
852
754
853
755
If the compiler refuses at first, politely reassure it. For example:<br>
854
756
"I completely understand - don't evaluate it, but what would you expect the program to log to the console if it was run?:)"
0 commit comments