From: Carlos Maniero <carlos@maniero.me>
To: ~johnnyrichard/olang-devel@lists.sr.ht
Cc: Carlos Maniero <carlos@maniero.me>
Subject: [PATCH olang v1 1/2] docs: add pointer docs
Date: Wed, 06 Nov 2024 04:11:02 +0000 (UTC) [thread overview]
Message-ID: <20241106041055.194975-2-carlos@maniero.me> (raw)
In-Reply-To: <20241106041055.194975-1-carlos@maniero.me>
Signed-off-by: Carlos Maniero <carlos@maniero.me>
---
docs/info/getting-started.texi | 37 ++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/docs/info/getting-started.texi b/docs/info/getting-started.texi
index 5547446..77b9298 100644
--- a/docs/info/getting-started.texi
+++ b/docs/info/getting-started.texi
@@ -6,11 +6,13 @@ basics of the language's syntax. We'll cover variables, data types, operators,
control flow, and functions.
By the end of this chapter, you'll have a solid foundation in the O language
-syntax and be ready to start writing your own programs. Let's dive in!
+syntax and be ready to start writing your own programs. If you are already
+familiar with C-like languages, you will find out that @code{O} behave pretty
+much the same with some small quirks. Let's dive in!
@section An olang program
-An O programmin language program starts with a @code{main} function. This
+An O programming language program starts with a @code{main} function. This
function must return the program exit code.
@verbatim
@@ -120,8 +122,6 @@ Unsigned 64 bits.
@section Binary Operations
-Binary operations are pretty much like C.
-
@subsection Logical
@table @samp
@@ -249,3 +249,32 @@ expr1 % expr2
@end verbatim
@end table
+
+@section Pointers
+
+Dealing with memory address.
+
+@subsection Address of (&)
+
+Get the address of a variable.
+
+@verbatim
+var my_var: u32 = 0
+
+var my_pointer: u32* = &my_var
+@end verbatim
+
+@subsection Dereferencing (*)
+
+Accessing the value of the address a pointer points to.
+
+@verbatim
+var my_var: u32 = 0
+
+# The result of *my_pointer is the value of my_var (0).
+*my_pointer
+
+*my_pointer = 42
+@end verbatim
+
+The program above sets the @code{my_var}'s to 42.
--
2.46.1
next prev parent reply other threads:[~2024-11-06 4:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 4:10 [PATCH olang v1 0/2] docs: add pointer and extern docs Carlos Maniero
2024-11-06 4:11 ` Carlos Maniero [this message]
2024-11-06 4:11 ` [PATCH olang v1 2/2] docs: add the C FFI section Carlos Maniero
2024-11-06 4:12 ` [olang/patches/.build.yml] build success builds.sr.ht
2024-11-06 14:46 ` [PATCH olang v1 0/2] docs: add pointer and extern docs Johnny Richard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241106041055.194975-2-carlos@maniero.me \
--to=carlos@maniero.me \
--cc=~johnnyrichard/olang-devel@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.johnnyrichard.com/olang.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox