-
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
Track Issue for HNM Grammar #2
Comments
What will we use for array subscription operation if we use brackets for function call? |
It may be...:
|
Wait... What is "array subscription operation"? Get the nth element of an array? I think we can make an array as a Magic (?, but I don't know how to impl it yet... It may be more complex...) |
just like in C int array[] = {1926, 0817};
printf("%d", array[1]); Java das not have a sugar like |
а на функщин, как на функщин. As far as I know, function or |
So I think... It may...:
like this? In this code, |
But I didn't come out with what is the array type looks like yet... And this problem may be too hard for me. |
So the idea is to make a "builder" or "constructor" function return an array. So, is the array a value type or reference type? |
It will be a value type, can be copied easily. |
Japanese “アレイ(arei)” is just the pronunciation of English “array”。I suggest using “Massiv” (русский:массив)。 |
Then it will be really hard to return an array from a function, just think about the array in C , |
I may not create a new type of keyword for |
Why? |
First of all, returning a value from a function involves copying the value from the stack frame of the callee to the stack frame of caller, which will be inefficient without RVO. What's more, values on stack are usually required to have fixed size, which will further limit the utility of array. |
QAQ |
Well, so |
but I think, the MaHouTsukai can:
|
Then you will need to extend lifetime of the array being returned, by moving it to heap area. And the caller in fact gets a reference |
|
According to Oracle doc:
Arrays are just |
My guess is right. |
Designing a programming language is TOO DIFFICULT! |
How about this kind of magic calling? :
This makes vararg can be anywhere, not only at the last parameter. |
Looks all fine but one thing: how does the callee's parameter list look like, and how will callee utilize these varargs? |
"I found it!" We can use |
Well... it will fall into left-recursion... |
|
Revert to |
How do we make capture? |
:( idk |
maybe [=, &a, &b](c: i32, d: i32) -> i32 { a + b + c + d + e } (the C++ way) However, since HNM may exploit a reference model, implying that there won't be different ways to capture a variable, the captures can be automatically deduced by compiler (like Java or JavaScript). Thus the explicit capture syntax is not necessary. |
fuck c++ |
data structure grammar: When we declare a variable using
It does this things:
|
declaring a data structure:
after that, use this type:
|
construct a structure:
Unchecked Construct is unsafe, it just wraps some magic bits into one box, without any layout checking. |
using field: As you see above, we can use an
|
All operators may have their context, including
So:
|
I don't know what does type parameter list look like, it must be friendly for type infering (omit type parameter purpose) |
I want something likes |
In the magic world, the notice doesn't exist in code but exists in the human mind. So IMO, |
However, it is very inconvenient. I need another solution. |
we use the
tag with some additional messages:
declaring a new
just replaced |
HNM must provide tailing recursive, the same as scala, HNM doesn't provide |
I want to impl one by myself. |
function type will be written in:
|
|
However, the grammar of HNM is not friendly for curring, we still need to support curring natively.
|
it will increase binary size... |
or not... I want a feature that can return value from a loop:
The loop in this code will run 2 times:
So |
ADT or sealed class:
and now, we can use the Pattern Matching operator:
|
I don't think the sealed class syntax is a good design, because |
I need a feature that allows the specific parameter is lazy without lambda syntax, for example (Java): String producer() {
System.out.println("Halo");
}
String foo(lazy Callable<String> bar) {
System.out.println("olaH");
return bar.call();
}
void main(String[] args) {
foo(producer());
} it prints:
it should be the same as: String producer() {
System.out.println("Halo");
}
String foo(Callable<String> bar) {
System.out.println("olaH");
return bar.call();
}
void main(String[] args) {
foo(() -> producer());
} |
Haskell has a nice design about Type Parameter, it also needn't declaration. But this depends on the Naming Style: But Types are starting with a lower letter in HNM. |
We are rarely using parentheses, but it is beauty... |
How about determining the priority by counting the spaces between the operators and operands? |
From the point of implementation, this would require a lexer which is able to read syntax trivia. Then parser will read these syntax trivia and determine precedence. I roughly knows how to write such a lexer/parser. |
Disallowed |
I had a super good idea but I forgot... |
Comment:
Magic (or Function):
Box Sugar Statement (or Let Statement):
Some Key Words:
Member Call:
Area Import (or Module Import):
Crash (or Panic/Throw):
SenTakuShi (or If Statement/Expr):
Repeat SenTakuShi (or Loop):
^2:
null
keyword:data structure definition
anonymous data structure
sequence (aka array)
The text was updated successfully, but these errors were encountered: