mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 13:20:10 +01:00
Also make minor updates to the skeletal design in docs/design/name_lookup.md following #2113, as there are no longer any prelude names that are made available to unqualified name lookup by default. Add `type` to the keyword list in docs/design/lexical_conventions/words.md, following #2360.
47 lines
884 B
Plaintext
47 lines
884 B
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
// More single line comments
|
|
|
|
package Carbon api;
|
|
|
|
interface HasValueParam(T:! type, V:! T) {
|
|
fn Go[self: Self]() -> T;
|
|
}
|
|
|
|
impl () as HasValueParam(i32, 5) {
|
|
fn Go[self: Self]() -> i32 { return 42; }
|
|
}
|
|
|
|
class Point {
|
|
fn Origin() -> Self {
|
|
return {.x = 0, .y = 0};
|
|
}
|
|
|
|
var x: i32;
|
|
var y: i32;
|
|
}
|
|
|
|
fn Procedure() -> i32 {
|
|
returned var zoop: i32 = 0;
|
|
while (DoSomeJob() {
|
|
zoop += 1;
|
|
}
|
|
|
|
return var;
|
|
}
|
|
|
|
fn Main() -> i32 {
|
|
let str = "Hello world";
|
|
let hex = 0xABCDEF1234567890;
|
|
let bin = 0b0000111001010010;
|
|
let dec = 123456789012345678;
|
|
|
|
let big: Carbon.Int(1024) = 1234;
|
|
let aaa: auto = "Carbon";
|
|
let view: StringView = "Carbon";
|
|
|
|
return Procedure();
|
|
}
|