-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pointer/array syntaxes #6
Comments
I'm tempted to suggest handling the weird intrinsics using an unnamed type which contains a 16-bit value and can be assigned to and from any pointer type. This would be useful for a variety of useful intrinsics (for example, a |
summarizing a conversation we had earlier regarding you suggested that maybe it was a mistake to name the nodes according to their semantic meaning rather than their text representation. i.e., you suggested that maybe instead of i see that instead as a yellow flag that maybe we shouldn't use we're so light on punctuation that it's not like it would be shooting ourselves in the foot by using a distinct operator for dereference, and i think not overloading operators is a good way to make the language more easily learnable. as for arrays... i don't understand the advantage of:
over:
what do the starting and end indexes mean? |
i do see value in wrapping the brackets around the type, to make it clear whether your dealing with an array of pointers or a pointer to an array of integers... but i don't see the value of the i'm tempted to suggest:
except i don't like overloading the colon. side note: this thing you're suggesting where you can do |
Okay, so let's assume we're gonna go with As for the range thing (ignoring Basically, the point of something like
... would be to allow you to declare an array with a custom range (useful for some algorithms?) where the type is laid out optimally for that. E.g. if you were to declare
Then the assembly emitted would be like:
... thereby allowing Possibly related, I was entertaining the idea of proposing an Ada/Pascal-style ability to create types like
... in which case |
okay, i'm on board with specifying non-zero-indexed array ranges. notes:
and, in reply to your |
semicolons. here's a multidimensional array:
|
arrays implemented in PR #20 |
Jonathoughts (tm):
for
statement as well.Hardware considerations
read-once
#5 for ideas on how to expose this desirable addressing mode to dynamic and mutable variables.Note that the Indexed addressing modes are indexed by a u8. Indexing with something bigger is probably a standard library concern.
Syntax ideas
Not in love with all of these. In particular, I don't know if I like
@
better than*
, though I do like it not being the same character as used for multiplication. I'm exercising it below to see if it grows on me at all.&
is probably fine for address-of; using it in the type instead of@
/*
provides symmetry with[]
and means that it can always be read as "address of" and@
/*
can be read as "target of", i.e.&u8
reads as "address ofu8
" and&foo
reads as "address offoo
". I stole this from Rust.We should probably distinguish between mutable pointers and read-only pointers. So C's
const int*
becomes&i16
and C'sint*
becomes&mut i16
. I have no desire to steal Rust's borrow checker because that is an undertaking and even Rust is having trouble getting it right. I'm fine with providing just basic support for making it clear what a function mutates and what it doesn't.I actually really like the idea of providing compiler intrinsics using function syntax, which can later be
promoted to "real" syntax if it proves useful. Rust uses
name!(args)
syntax for this (and macros), but I'm not really in love with that.Note that pointer types don't have arithmetic defined on them--the
mem.as-address
andmem.as-pointer
functions have to be used to convert them. Pointer arithmetic on the C64 is generally pretty slow compared to direct indexing, so I'm inclined to steer people away from it.The text was updated successfully, but these errors were encountered: