The Artima Developer Community
Sponsored Link •

C# Answers Forum
Stack-based's Limitation

1 reply on 1 page. Most recent reply: Apr 19, 2004 11:08 AM by Mike Swaim

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
le Thuy

Posts: 1
Nickname: lequang
Registered: Nov, 2003

Stack-based's Limitation Posted: Nov 27, 2003 10:47 AM
Reply to this message Reply
Advertisement
Can anyone explain why a funtion cannot construct any data structure whose size is not known to the caller on the stack?
Is it because of the stack structure? Is there any mechanism that languages use to overcome this limitation?
thank you


Mike Swaim

Posts: 13
Nickname: swami
Registered: Apr, 2004

Re: Stack-based's Limitation Posted: Apr 19, 2004 11:08 AM
Reply to this message Reply
> Can anyone explain why a funtion cannot construct any data
> structure whose size is not known to the caller on the
> stack?
> Is it because of the stack structure?
Yes. Objects are located contiguously on the stack. If the caller doesn't know how big the object is, it can't know how much space to reserve, can it?

> Is there any
> mechanism that languages use to overcome this limitation?
Pointers. (Or object references.)

Flat View: This topic has 1 reply on 1 page
Topic: need code Previous Topic   Next Topic Topic: help please!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use