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

function prototypes #158

p5pRT opened this issue Jul 3, 1999 · 1 comment

function prototypes #158

p5pRT opened this issue Jul 3, 1999 · 1 comment


Copy link

p5pRT commented Jul 3, 1999

Migrated from (status was 'resolved')

Searchable as RT963$

Copy link

p5pRT commented Jul 3, 1999

From @vlbrown

If I declare (and or define) my function before I use it

  sub func() {
  return 1;

  $returned = func(17);

  print $returned;

Then I get a fatal error if the protptype doesn't match.

  Too many arguments for main​::func at line 7, near "17)"
  Execution of aborted due to compilation errors.

However, if the function is not declared until after the call

  $returned = func(17);

  print $returned;

  sub func() {
  return 1;

There is no error (fatal or otherwise).

This violates the Principle of Least Astonishment.

I could buy the argument that this is Difficult To Solve. I think it's a bug
even so.

Nevertheless, it would be useful at least if -w would warn about
  Prototype declared too late in code
or something similar so that folks like me who put the functions at the end of
the script would have some warning (and folks who <shudder> mistakenly use
C-style declarations of functions would at least hear from -w).

Perl Info

Site configuration information for perl 5.00502:

Configured by rdm at Sun Feb  7 16:25:31 PST 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
    osname=freebsd, osvers=2.2.8-release, archname=i386-freebsd
    uname='freebsd 2.2.8-release freebsd 2.2.8-release #0: fri jan 15 18:39:18 pst 1999 i386 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
    cc='cc', optimize='-O', gccversion=
    ccflags ='-I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=true
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-ldb -lm -lc -lcrypt
    libc=/usr/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-DPIC -fpic', lddlflags='-Bshareable  -L/usr/local/lib'

Locally applied patches:

@INC for perl 5.00502:

Environment for perl 5.00502:
    LANG (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

1 participant