필터 지우기
필터 지우기

Strange limitations on script files?

조회 수: 3 (최근 30일)
Klaus-Dieter
Klaus-Dieter 2023년 9월 22일
답변: Walter Roberson 2023년 9월 23일
Just wanted to clarify: Are there specific reasons to enforce scripts to
  • have function definitions only at the end of the file
  • disallow classdef in script files
?
This feels especially unnatural in live scripts, where it disallows naturally adding functions or data structures in the course of the document.
  댓글 수: 1
dpb
dpb 2023년 9월 22일
I have absolutely no inside knowledge, but I would presume the reason is to make the parsing/compilation of code simpler by minimizing complexity.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2023년 9월 23일
  • Not allowing function definitions in the middle of a script file removes ambiguity about whether code after a function definition is there accidentally (such as if there is an extra end in the code)
  • requiring that classdef be the only (non-comment) thing in the file removes ambiguity about what exactly is executed when the class is defined or invoked.

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by