Skip to content
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

swesterman/23 11 07/kernel #1640

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

sampersand
Copy link
Contributor

  • updating kernel
  • more updates
  • more updates
  • q

@sampersand
Copy link
Contributor Author

(this requires a few of my other commits to be merged before I finalize this)

core/kernel.rbs Outdated Show resolved Hide resolved
Comment on lines -1304 to -1307
def self?.rand: () -> Float
| (Integer arg0) -> Integer
| (::Range[Integer] arg0) -> Integer
| (::Range[Float] arg0) -> Float
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you finished self?.rand? My IRB accepts both 0.0 and 0..0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I havent, it's one of the remaining functions left. It's really weird.

Comment on lines +1583 to +1589
interface _Timeout
def divmod: (1) -> [int, _TimeoutNSecs]
end

interface _TimeoutNSecs
def *: (1000000000) -> int
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation details talk aside – what classes beside Integer sastisfies the _Timeout interface, interstingly?

4.5.divmod(1)[1] * 1000000000 #=> 500000000.0

Comment on lines +1701 to +1709
def self?.test: (
'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'G' | 'k' | 'o' | 'O' | 'p' | 'S' | 'u' | 'z' |
98 | 99 | 100 | 101 | 102 | 103 | 71 | 107 | 111 | 79 | 112 | 83 | 117 | 122,
IO | path file) -> bool
| ('l' | 'r' | 'R' | 'w' | 'W' | 'x' | 'X' | 108 | 114 | 82 | 119 | 87 | 120 | 88, path filename) -> bool
| ('s' | 115, IO | path filename) -> Integer?
| ('M' | 'A' | 'C' | 77 | 65 | 67, IO | path file) -> Time
| ('-' | '=' | '<' | '>' | 45 | 60 | 61 | 62, IO | path file1, IO | path file2) -> bool
| (String | int cmd, IO | path file1, ?IO | path file2) -> (bool | Integer? | Time)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only valid options are specified in the docs i guess … ? 🤷

Comment on lines -1717 to -1792
# <!--
# rdoc-file=process.c
# - exec([env,] command... [,options])
# -->
# Replaces the current process by running the given external *command*, which
# can take one of the following forms:
#
# `exec(commandline)`
# : command line string which is passed to the standard shell
# `exec(cmdname, arg1, ...)`
# : command name and one or more arguments (no shell)
# `exec([cmdname, argv0], arg1, ...)`
# : command name, `argv[0]` and zero or more arguments (no shell)
#
#
# In the first form, the string is taken as a command line that is subject to
# shell expansion before being executed.
#
# The standard shell always means `"/bin/sh"` on Unix-like systems, otherwise,
# `ENV["RUBYSHELL"]` or `ENV["COMSPEC"]` on Windows and similar. The command is
# passed as an argument to the `"-c"` switch to the shell, except in the case of
# `COMSPEC`.
#
# If the string from the first form (`exec("command")`) follows these simple
# rules:
#
# * no meta characters,
# * not starting with shell reserved word or special built-in,
#
#
# Ruby invokes the command directly without shell.
#
# You can force shell invocation by adding ";" to the string (because ";" is a
# meta character).
#
# Note that this behavior is observable by pid obtained (return value of spawn()
# and IO#pid for IO.popen) is the pid of the invoked command, not shell.
#
# In the second form (`exec("command1", "arg1", ...)`), the first is taken as a
# command name and the rest are passed as parameters to command with no shell
# expansion.
#
# In the third form (`exec(["command", "argv0"], "arg1", ...)`), starting a
# two-element array at the beginning of the command, the first element is the
# command to be executed, and the second argument is used as the `argv[0]`
# value, which may show up in process listings.
#
# In order to execute the command, one of the `exec(2)` system calls are used,
# so the running command may inherit some of the environment of the original
# program (including open file descriptors).
#
# This behavior is modified by the given `env` and `options` parameters. See
# ::spawn for details.
#
# If the command fails to execute (typically Errno::ENOENT when it was not
# found) a SystemCallError exception is raised.
#
# This method modifies process attributes according to given `options` before
# `exec(2)` system call. See ::spawn for more details about the given `options`.
#
# The modified attributes may be retained when `exec(2)` system call fails.
#
# For example, hard resource limits are not restorable.
#
# Consider to create a child process using ::spawn or Kernel#system if this is
# not acceptable.
#
# exec "echo *" # echoes list of files in current directory
# # never get here
#
# exec "echo", "*" # echoes an asterisk
# # never get here
#
def self?.exec: (String command, *String args, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: boolish, ?chdir: String) -> bot
| (Hash[string, string?] env, String command, *String args, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: boolish, ?chdir: String) -> bot

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted?

@@ -2103,7 +2079,7 @@ module Kernel : BasicObject
# Returns true if two objects do not match (using the *=~* method), otherwise
# false.
#
def !~: (untyped) -> bool
def !~: [T] (T other) -> bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The [T] here has no practical effect.

Comment on lines +2298 to +2300
# if no method is given, defaults to `each`
# size is enum's yield
# ^ todo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

core/kernel.rbs Outdated Show resolved Hide resolved
@@ -2759,7 +2750,7 @@ module Kernel : BasicObject
#
# 1.public_send(:puts, "hello") # causes NoMethodError
#
def public_send: (interned name, *untyped args) ?{ (*untyped) -> untyped } -> untyped
def public_send: (interned name, *untyped args, **untyped kwargs) ?{ (*untyped, **untyped) -> untyped } -> untyped
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -2965,17 +2939,34 @@ module Kernel : BasicObject
# then {|url| URI(url).read }.
# then {|response| JSON.parse(response) }
#
def yield_self: [X] () { (self) -> X } -> X
def yield_self: [T] () { (self) -> T } -> T
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would conventions use R for Return?

Suggested change
def yield_self: [T] () { (self) -> T } -> T
def yield_self: [R] () { (self) -> R } -> R

sampersand and others added 2 commits November 24, 2023 05:38
Co-authored-by: ParadoxV5 <[email protected]>
Co-authored-by: ParadoxV5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants