subroutine Questions

3

Solved

I find that in RISC-V, ra is caller saved, in MIPS, ra is callee, which means in RISC-V callee can directly change the value in ra without save, but since ra has changed, how callee return back to ...
Breakneck asked 11/1, 2020 at 9:52

4

Solved

Perl provides an API via CORE::prototype, that allows you to get a prototype. This is further documented by Sub::Util which is the documented method for working with subs, Sub::Util::prototype, Re...

1

Solved

This code works as expected: sub infix:<mean>(*@a) { @a.sum / @a.elems } sub Mean (*@a) { @a.sum / @a.elems } say EVAL 'Mean 2, 6, 4'; # Output: 4 say EVAL '2 mean 6 mean 4'; # Output: 4 ...
Rosenbaum asked 2/7, 2023 at 0:36

5

Solved

The AutoHotkey command Hotkey allows for the creation of dynamic hotkeys at runtime, but its syntax and documentation seems to limit it to built-in or existing labels/subroutines, which makes it mu...
Names asked 12/10, 2012 at 3:12

2

Solved

I am getting this error when running perl: [Thu Mar 16 00:24:23 2023] list_directory_1.cgi: Subroutine main::getcwd redefined at /usr/lib/cgi-bin/list_directory_1.cgi line 15. I think it is comin...
Madelainemadeleine asked 16/3, 2023 at 0:42

1

Solved

Given the following code: sub foo { say 'Hello'; } my $call_me = 'foo'; How do I call the sub foo using $call_me?
Sunil asked 24/7, 2022 at 1:26

1

Solved

It seems that a a sub cannot access dynamic variables when it is used inside a map and that map is "return"ed. Consider this piece of code: sub start { my $*something = 'foobar'; # WO...
Zadazadack asked 20/12, 2021 at 19:26

5

Some Perl books advise using parentheses when calling class methods, saying this helps to keep the parser from having to guess the intent of the code. However almost all Perl code I have seen (incl...
Diddle asked 27/8, 2014 at 9:50

2

Solved

Consider: program main real, allocatable, dimension(:) :: foo integer n n=10 call dofoo(foo,n,1) allocate(foo(n)) call dofoo(foo,n,0) end program main subroutine dofoo(foo,n,mode) real foo(n) int...
Marcheshvan asked 21/11, 2012 at 15:28

2

... #!/usr/bin/env raku # -*-perl6-*- # 2021-5-30: Example of how a sub does not seem to be able to return 2 Hashes... sub GetHashes { my %H = 100 => 2149, 101 => 2305, 102 => 2076, 10...
Apodal asked 30/5, 2021 at 22:3

3

Solved

I would like to detect how a subroutine is called so I can make it behave differently depending on each case: # If it is equaled to a variable, do something: $var = my_subroutine(); # But if it's...
Declarer asked 20/8, 2013 at 14:10

2

I have seen both "subroutine" and "routine" used in programming language books. Are they the same concept? What does "sub-" mean? I guess there are many examples which you might have seen in compu...

6

I have a Perl file like this: use strict; f1(); sub f3() { f2(); } sub f1() {} sub f2() {} In short, f1 is called before it is defined. So, Perl throws a warning: "f1 called too early to check...
Gadroon asked 12/11, 2009 at 5:0

2

Solved

VBA question. I'm using it to make Solidworks macros, but that's not important. Can someone explain the syntax to pass an array (1-Dimensional of type Double, with length of three) to a subroutine...
Polyphony asked 4/2, 2015 at 16:28

3

Solved

I want a script to run a subroutine exported from a module, with the exported sub to be run as MAIN in the script. The subroutine does all that I want, except that it returns the result instead of ...
Votaw asked 19/11, 2019 at 18:55

5

Solved

I was asked to modify some existing code to add some additional functionality. I have searched on Google and cannot seem to find the answer. I have something to this effect... %first_hash = gen_fi...
Sour asked 21/7, 2009 at 18:54

2

Is a plain RETURN statement (without any arguments) just before END SUBROUTINE in large legacy codes a good practice or should we just remove it? The code I am working with is a big legacy code (f...
Humidifier asked 6/11, 2019 at 6:4

1

Solved

Scenario Imagine that you have a module X whose functionalities are available to the user through a Command Line Interface. Such module doesn't do much in and of itself but it allows for other peo...
Constantine asked 15/7, 2019 at 13:41

2

Solved

Is it possible to assign methods to variables and pass them around as arguments inside the class similar to subroutines? I know they're are accessible by either self. or self! (or whatever named e...
Eternity asked 15/7, 2019 at 13:47

7

Solved

Both "Exit Sub" or "Return" seem to accomplish the same thing -- exit a subroutine. Is there any difference in how they work under the covers? That is, Private Sub exitNow() Exit Sub End Sub o...
Phuongphycology asked 17/6, 2009 at 1:20

3

Solved

I want to use a superclass sort which uses a subclass compare function. I've tried to distill the nature of the question in the following code. This isn't the "production" code, but is presented he...
Natter asked 23/2, 2019 at 14:25

9

I don't know how to set default arguments for subroutines. Here is what I considered: sub hello { print @_ || "Hello world"; } That works fine for if all you needed was one argument. How would ...
Trichloride asked 22/8, 2010 at 21:49

4

Solved

I don't grok Perl subroutine attributes at all. I have never seen them in actual code and perldoc perlsub and the perldoc attributes fail to answer my questions: What are attributes useful for? ...
Kirimia asked 10/12, 2011 at 10:55

4

Solved

So I have a file that in short has this problem... #!/usr/bin/perl -w package Foo; use strict; use POSIX; ... sub remove { ... } ... and I get a get an error saying the subroutine remove has...
Spital asked 29/8, 2010 at 2:56

1

Solved

Has Fortran ever gotten around to handling subroutine argument lists with arbitrary length, like C can do? (BTW, "present" isn't going to work for what I am trying to do.) Thanks.
Unclench asked 30/8, 2018 at 14:51

© 2022 - 2024 — McMap. All rights reserved.