Thanks, Petr,
With regard to RUST's immutability rules, Would this construction be acceptable:
do { let a=inkey() if a<32 { exit do } }
A language without variables and only constants would surely send me over the edge.I'm intrigued by immutability. Do you find it useful in RUST?
Thanks, Petr,
With regard to RUST's immutability rules, Would this construction be acceptable:
do { let a=inkey() if a<32 { exit do } }
Rust variables are immutable by default, but you can override it using mut. In other languages, they are mutable by default but you can use const to make it immutable. So, the same rules, but reversed.
How are arguments passed to a function viewed in Rust? Is there any concept of LOCAL?
Constants can only be defined in terms of other constant expressions. They can be resolved at compile-time, whereas immutables may also be set by variable expressions in run-time (once only).
I'm interested in providing an immutability mode in o2, but I am puzzled as to how it could be used advantageously.
PS:
RUST has local variables, and parameter passing byval / byref, much the same as C / Basic.
i believe the Rustologists only rename the jargon of C/Basic, beautifying it with Philosophy .
i have stopped to learn Rust after looking at this (simple program!!)
https://stackoverflow.com/questions/...g-to-hit-enter
will focus on Basic Languages onlyextern crate termios; use std::io; use std::io::Read; use std::io::Write; use termios::{Termios, TCSANOW, ECHO, ICANON, tcsetattr}; fn main() { let stdin = 0; // couldn't get std::os::unix::io::FromRawFd to work // on /dev/stdin or /dev/tty let termios = Termios::from_fd(stdin).unwrap(); let mut new_termios = termios.clone(); // make a mutable copy of termios // that we will modify new_termios.c_lflag &= !(ICANON | ECHO); // no echo and canonical mode tcsetattr(stdin, TCSANOW, &mut new_termios).unwrap(); let stdout = io::stdout(); let mut reader = io::stdin(); let mut buffer = [0;1]; // read exactly one byte print!("Hit a key! "); stdout.lock().flush().unwrap(); reader.read_exact(&mut buffer).unwrap(); println!("You have hit: {:?}", buffer); tcsetattr(stdin, TCSANOW, & termios).unwrap(); // reset the stdin to // original termios data }
BUT i will stay watching the subject occasionally
Too complex to me
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Here is the Script BASIC version of the GetKey Rust program.
IMPORT CIO.sbi Start: PRINT "Hit a key! " buffer = CIO::getch() IF buffer = 27 THEN GOTO Done PRINT "\nYou have hit: ","[",FORMAT("%~000~",buffer),"] - ",CHR(buffer),"\n" GOTO Start Done:
C:\ScriptBASIC\examples\test>scriba getch.sb
Hit a key!
You have hit: [001] - ☺
Hit a key!
You have hit: [002] - ☻
Hit a key!
You have hit: [003] - ♥
Hit a key!
You have hit: [065] - A
Hit a key!
You have hit: [098] - b
Hit a key!
You have hit: [067] - C
Hit a key!
C:\ScriptBASIC\examples\test>
Last edited by John Spikowski; 10-07-2018 at 07:36.
Thanks John for the code. evidently we can know what it is doing since it is natural and readable, i have tested it after adding IMPORT "cio.bas" for the windows version.
this is one possibility for Thinbasic
it will return the pressed character until we press ESC.Uses "Console" String a PrintL "Press ESC key to end program" While a<>"[ESC]" a = WaitKey PrintL a Wend
i just don't know why Eros have added "[]" to the captured character, but it is not a problem at all.
i think the programming language should not waste the Human Brain limited resources (100 billion neurons damaged by the Pollution, wars, Politics... ) especially in this noisy world with all the flood of information processed by the Mind so the designers of programming language should take care of this fact.
Reason is because WaitKey is able to get special multiple key press combination like in the following example:
Using [] seemed to me a convenient way to get all possibilities.Press ESC key to end program [CTRL][PGUP] [SHIFT][CTRL][PGDOWN] [SHIFT][CTRL][END] [SHIFT][CTRL][DOWN] [SHIFT][CTRL][RIGHT] [CTRL][UP] [CTRL][DOWN] [CTRL][LEFT] [CTRL][RIGHT] [ALT][LEFT] [ALT][RIGHT] [ALT][DOWN] [ALT][UP] [ALT][q] [ALT][Q] [ALT][e] [ALT][c] [ALT][d]
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Bookmarks